Getting Image Preview jQuery?

Your implementation works to a point, I've had a go at changing it to do a little more of what you hoped for. Hope it helps jsfiddle.net/W69aA/10 script> $('. Test').

Blur(function() { var src = jQuery(this).val(); var LinkedImage = $(this). Data('linkedImage'); $(LinkedImage).remove(); if(!src. Match("http:\/\/.

*\/(.*)\.(jpg|jpeg|png|gif)") && src! = "") { $("#warning"). Html("Must be an image"); return false; } else { $("#warning").

Html(""); } if (src! = "") { $('#prev'). Append(''); $(this).

Data('linkedImage', $('img:last' ,'#prev')); } }).

Your implementation works to a point, I've had a go at changing it to do a little more of what you hoped for. Hope it helps. jsfiddle.net/W69aA/10.

Thanks a lot :) I think the .match() might work better if its ...match(/http:\/\/\S+(\. Png|\. Jpg|\.

Gif)/g);? Also, trying to figure it out - but the image preview seems to appear - console shows the error Resource interpreted as Image but transferred with MIME type application/json. In Chrome – Tom Aug 24 at 17:20 i.e.As this fails for me educ661-373wikiarticle.wikispaces.

Com/file/view/test. Jpg/…? Also, if I remove the input link - the preview remains?

– Tom Aug 24 at 17:26 I'll take a look. I was using firefox, didn't think to try anything else. – Henry Garle Aug 24 at 17:41 When you remove the link it disappears for me.

Take a look in Firefox see if it makes any difference. – Henry Garle Aug 24 at 17:44 yeah noticed that in FF. Not sure what's going on in Chrome?

See the console - i'm trying to fix that p. S - awesome effort. :) – Tom Aug 24 at 17:45.

The first thing you probably want to change is add src == "" to check for empty strings when you validate the value of the input. If (src == null || src == undefined) { Check out this fiddle you can validate if it is an image using this regex if(!src. Match("^https?

://(?:a-z\-+\. )+a-z{2,6}(?:/^/#? +)+\.(?:jpg|gif|png)$")) { alert("must be an image") return false; } Your final code would look something like this $('.

Test'). Blur(function() { var src = jQuery(this).val(); if(!src. Match("^https?

://(?:a-z\-+\. )+a-z{2,6}(?:/^/#? +)+\.(?:jpg|gif|png)$")) { alert("must be an image") return false; } var prevImg = jQuery('#prev > id^="prevMe-"').

Length; if (src == null || src == undefined || src == "") { //trying to remove image if it's the same value or input is emptied jQuery('#prevMe-' + (prevImg - 1)).remove(); } else { jQuery('#prev'). Append(''); } }).

Thanks a lot for trying :) I did try the image i.e. Try - educ661-373wikiarticle.wikispaces. Com/file/view/test.

Jpg/…) and it keeps giving me a error? Also it doesn't remove the prev-image if the link is removed from the input? – Tom Aug 24 at 17:06.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions