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

ImageScaletoFit Issue

Guest
May 21, 2013 May 21, 2013

Copy link to clipboard

Copied

<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!

Views

583

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

^_^

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

So how should it look then?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Documentation