$(function(){
// JUST FOR THE DEMO
var randNum = Math.floor((Math.random()*2)+1);
var pathsChoices = {"1":"/images/RESOURSES/im123.jpg",
"2":"/images/PDF/im123.jpg"};
var imgPath = pathsChoices[randNum];
// END OF DEMO'S RELATED VARS
// resultIP is the response image path
var imgDirectory = imgPath.split('/'); // cuts into: '','images','PDF','im123.jpg'
$('body').append('<p>Path selected is: '+imgPath+'.</p>');
alert('the directory is: '+imgDirectory[2]);
// Compare the directory
if(imgDirectory === "PDF"){
// do something if PDF
}else{
$('#Imgsrc').attr('src',imgPath);
}
});
From above code i m able to get the folder name ,how to find the actual width and the height of image bcoz if image coming from folder need to have width:640 else width:450
plz suggest
html
<div id="ScrapZoomImg">
<img src="" id="Imgsrc" width="640" border="0" alt=""/>
</div>