|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
maximum image size
I am trying to display images with paths stored in a database, and wanted to make the maximum width of the image to be 500...
<cfoutput query="spec_pic" maxrows="1"> <img src="http://127.0.0.1:8500/videos/#spec_pic.filename#" width="500"> </cfoutput> ------------ however, i want to make it so it only forces the maximum width if the image width is greater than 500. Is there any built in variables made to retieve this info on the image or any other way to complete this task? Mayber javascript? |
|
#2
|
|||
|
|||
|
you're right about the javascript - give the img element an id tag & an onLoad handler, then in the handler test the image.width, .height and adjust if necessary
|
|
#3
|
|||
|
|||
|
You can get the image dimensions using cfx_image, the Java Advanced Imaging API (downloadable add-on to the core Java runtime), or something like the Alagad Image Components. I'm sure there are others as well, try Googling or searching the Macromedia Exchange.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
Here you go
I didnt have a DB to work from but I am sure you can change this to suite your needs ....
Code:
<Cfset imglist = "1,2,3,4,5,6">
<cfoutput>
<Cfloop list="#imglist#" index="img">
<script language="JavaScript">
function resizeImg(othis){
myImage = new Image()
myImage.src = othis.src;
if(myImage.width > 500){
othis.width = 500
}
}
</script>
<img src="images/#img#.jpg" name="#img#" onload="resizeImg(this)"><br>
</CFLOOP>
</cfoutput>
|
|
#5
|
|||
|
|||
|
Quote:
looks good, if you move the javascript outside of the loop. (More of a picky thing, use var for method-local variables to avoid blatting global ones) |
|
#6
|
|||
|
|||
|
nice thanks
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > maximum image size |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|