How to avoid img error icon - html

If you give an src and it cannot find the img it usually appears a square with a X. Is there any way to avoid that? I mean if it cannot find the img, just show nothing
You can check your solution here:http://jsfiddle.net/GmBax/
HTML:
<img src="1.png" width="42" height="42" >

There's another option, you can load a default empty image on error. Ex: <img src="/img.jpg" onerror="this.src='/none.jpg'" />

put in an "alt" and a "title" tag - this way if the image doesn't show, the alt text will show instead.
e.g.
<img src="1.png" width="42" height="42" alt="hello" title="hi">

Use the alt parameter for example.. You can either add a text or leave it empty.
<img src="1.png" width="42" height="42" alt="" />
Or handle it by some PHP or whatever you're using.

Related

Local image doesn't work on markdown with <img

I'm trying to use markdown to generate a documentation. When i use <img alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" src='http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg'/> it's working and it shows the image but when i put <img alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" src='test.jpg'/> doesn't work although the image test.jpg is on the same folder with the mardown file.
I want to use <img because i want to align my image to the center !
The first one
<img alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" src='http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg' />
works because the image source is from img.youtube.com
The second one
<img alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" src='test.jpg'/>
has a local stored image source from your computer. As far as I know it is not only enough to enter the name of the picture but you must also write in your path.
Try something like this (example)
src="C:\Users\YourPCName\Documents\YourSaveFolder\test.jpg
Please note that you have to change the path accordingly when uploading to a webspace/server in general.
Let me know if it works!
Cheers,
Kevin

How to Set Default Image in Html If the original image is not visible or gives Error

How can we set default image in case if original image is not loaded or gives error and shows only alt text in place of image in html
try this way
<img id="currentPhoto" src="SomeImage.jpg" onerror="this.onerror=null; this.src='https://homepages.cae.wisc.edu/~ece533/images/airplane.png'" alt="" width="100" height="120">
Use onerror for this issue

How to insert image in placehold.it

I'm use http://placehold.it to put image size,but I don't know how to insert image,for example :
<img src="image/abc.png" alt="" />
and when i use placehod.it as src="https://placehold.it/320x150"
You can use placeholder image by just requesting the following URL:
http://placehold.it/300x200
The first parameter defines the width and the second parameter is height.
<img src="http://placehold.it/200x200">
http://placehold.it is just provide dummy images to fill up your content. You don't use it to set the image size. Use this:
<img src="image/abc.png" style="width:320px;height:150px" alt="" />

image attributes appearing priority

<img src="#" alt="abc"/>
after above code rendered in browser the position of alt and src are changed like
<img alt="abc" src="#"/>
Is there is any way to fix these problem
"I want that every time src comes before others attributes!"

How do I solve this issue in IE7?

When I am testing my page in IE7, all the image have a tooltip corresponding to the text of the alt in the image tag..
<img src="Myimage.jpg" alt="No pic" />
When I hover my mouse on the displayed pic in IE7, I get a tooltip "No pic" corresponding to the text of the alt .How do I fix this ?
IE6/7 treats the alt attribute as though it was a title attribute - but only if there's no actual title attribute set.
You can workaround it with a blank title:
<img src="Myimage.jpg" alt="No pic" title="" />
You can try adding an empty title tag
<img src="image.jpg" alt="nopic" title="" />
The answer has been posted already (empty title tag).
However, (in reference to one of the answers) alts are supposed to describe the image for 508 compliance reasons and if the image doesn't show up, so you should change the alt text to describe your picture.
I would have made a comment on the original post but SO doesn't allow me to yet.
The actual question here is why are you using alt the way you are? If your image is simply decorative, you should have an empty alt attribute. look at the W3CS definition of the alt attribute.
http://www.w3.org/QA/Tips/altAttribute
On this occasion is suspect youd actually want:
<img src="Myimage.jpg" alt="" />