Skip to main content

Handling MISSING Image in HTML

It often happens that we allow users to upload a profile pic. But all the users do not upload a pic. Thus either we have to copy the same template image for all users or we get a broken image in the page. To fix this, use onerror code.
Approach 1 - Hide the image if no image is available.

onerror="this.style.display='none'"

Approach 2 - Use a template / filler image.
onerror="this.src='fallback-img.jpg'"

Comments

Popular posts from this blog

WhatsApp for Windows stuck in Fullscreen

In case your whatsapp for windows is stuck in fullscreen, close Whatsapp and open the following file. C:\Users\ username \AppData\Roaming\WhatsApp\settings.json where username is your login ID in windows. The file can be opened with Notepad or any text editor. Change "isFullScreen":true to "isFullScreen":false Save the file and start WhatsApp. Now you can change the size of the window. (If required, you can change the size of whatsapp window from the json file too.

Installing SSL in a Site in Sentora / Cent OS

In Console yum install certbot python2-certbot-apache mod_ssl openssl (If it shows any error, then  yum install epel-release and run above command again) THIS WAS NOT REQUIRED WHEN I WORKED ON CSMCL.IN. So this step can be dropped. Comment listen 443 to #listen 443 in  /etc/httpd/conf.d/ssl.conf using NANO (Still to figure out if above line is mandatory or not. Will check when installing it in third server) THERE ARE 2 DASHES BEFORE APACHE BELOW. certbot –apache for enabling ssl in all sites on the server certbot –apache –d domain1 –d domain 2 for enabling ssl on selected domains if it fails, use certbot -d domain1 -d domain2  (using -apache causes issue in some systems) Rest is fully automatic Later Check certs certbot certificates One click renew all expiring certs certbot renew /// In case you have to delete a cert certbot revoke -- cert - path / etc / letsencrypt / live / CERTNAME / cert . pem certbot delete --...

CRON Jobs

In Sentora Environment, CRON Jobs can be run using Root Level Crons or Sentora Crons. If it is a system level command like restarting services or backup outside the root, then system level cron should be used. For running php scripts like sending daily summary, mailing database backup, etc then Sentora cron should be used.