This is my problem and that is my idea. I think this is difficult thing to solve it.
My issue is We can or can't check 'image tag' is empty or wrong path. For instance,so i get image url from other website and when this image not exist (can removed) or i give wrong url ...
I mean if the img tag with src=empty or wrong path or image file is not exist .we can check it and replace them by nopicture photo (look like src="images/nopicture.jpg") . I really want to know we can or
can't do that.
I already read this Post and that is check src is empty ,right?
vietvoquoc
Member
16 Points
32 Posts
How to Check image tag (<img) or Control Image is empty or wrong path ??
May 05, 2012 02:47 PM|LINK
Hello everyone!
This is my problem and that is my idea. I think this is difficult thing to solve it.
My issue is We can or can't check 'image tag' is empty or wrong path. For instance,so i get image url from other website and when this image not exist (can removed) or i give wrong url ...
I mean if the img tag with src=empty or wrong path or image file is not exist .we can check it and replace them by nopicture photo (look like src="images/nopicture.jpg") . I really want to know we can or can't do that.
I already read this Post and that is check src is empty ,right?
Hope helped from everyone!Please and thank you!
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: How to Check image tag (<img) or Control Image is empty or wrong path ??
May 05, 2012 02:52 PM|LINK
http://stackoverflow.com/questions/980855/inputting-a-default-image-in-case-the-src-arribute-of-an-html-img-is-not-valid
Space Coast .Net User Group
Ruchira
All-Star
42884 Points
7019 Posts
MVP
Re: How to Check image tag (<img) or Control Image is empty or wrong path ??
May 06, 2012 07:32 AM|LINK
Hello,
you can use onerror method of the image tag to set a default content place holder if the images is not found or broken.
<img onerror="test(this);" src="......." /> function test(e) { e.src="images/nopicture.jpg"; }
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.vietvoquoc
Member
16 Points
32 Posts
Re: How to Check image tag (<img) or Control Image is empty or wrong path ??
May 10, 2012 02:55 AM|LINK
Apology bcz i reply late!!
Thanks for help me.And now i solved my problem with both of ways that you give me.
That's very strange to me and very useful to avoid problem with image.
Thanks both of you and have a good day.!