Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ImageScaletoFit Issue

Guest
May 21, 2013 May 21, 2013

<tr><cfoutput query="myDirectory" maxrows="1">

<td align="center"><a href="#Name#">

<cfimage source="#Name#" name="Name1">

<cfset ImageScaleToFit(Name,200,"")><!---  ---><img src="#Name#" /><br />#Name#</a></td>

<cfif myDirectory.currentRow MOD 3 EQ 0>

</tr>

<tr>

</cfif></cfoutput>

Whenever I try the code above I get the following error "

Unable to cast an object of type java.lang.String to Image.

"

How can I use this tag and resize images that are stored in the variable Name and get them to display correctly?  HELP!

600
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2013 May 21, 2013

You scale the image, first, then use CFIMAGE action="writetobrowser" to display it.

^_^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 21, 2013 May 21, 2013

So how should it look then?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2013 May 21, 2013
LATEST

According to Adobe CF docs, resizing an image is done as:

<cfimage
    required
    action = "resize"
    height = "number of pixels|percent%"
    source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#"
    width = "number of pixels|percent%"
    optional
    destination = "absolute pathname|pathname relative to the web root"
    isBase64 = "yes|no"
    name = "cfimage variable"
    overwrite = "yes|no">

Then, writing it to the browser is like:

<cfimage action="writetobrowser" source="#image name from first cfimage tag#" format="gif" id="yourID" />

^_^

UPDATE: I just noticed ImageScaleToFit.  Sorry. Place the following between the first two tags I wrote:

<cfset ImageScaleToFit(image name from first cfimage tag,options)>

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7975.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources