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

Coldfusion variable in img tag source produces weird output

Community Beginner ,
Feb 21, 2010 Feb 21, 2010

Hey again. Straight to the point as i'm getting grey haired caused of this:

<cfscript>objMonkehTweet2 = createObject('component','cf_components.coldfumonkeh.monkehTweet').init('#get_info.user_name#','#ToString(BinaryDecode(get_info.pass_word, "base64"))#',true);
    result2 = objMonkehTweet2.getUserDetails(id='#get_info.user_name#'); 
   </cfscript>
      <cfoutput>#result2.user.profile_image_url#</cfoutput>
       <div id="twitter_label"><span style="float:left">Update IGES Twitter status:</span><span style="float:right"><a href="upd_news.cfm">add new slide</a></span></div>
        <img name="" src="<cfoutput>#result2.user.profile_image_url#</cfoutput>" width="44" height="44" style="border:0; float:left" />

(script calls twitter API)

result:

img tag nonsence.jpg

As you see the script output displays correct path to the the image. However, exactly the same cfoutput inserted inside image tag produces this weird output with the whole address printed out and image tag end in the end. There are no " > or other similar symbols in the address as you can see so why?????

cheers,

Simon

1.3K
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

correct answers 1 Correct answer

LEGEND , Feb 21, 2010 Feb 21, 2010

Well, first question: do you want to pass back XML and then need to extract your URL value, or do you just want to pass back the URL by itself in the first place?  There's arguments & use cases both ways.

As to how to extract it, it depends on what the possible content of that XML packet might be.  Is its structure always going to be a single node with just the profile_image_url value?  If so you can just access it directly with result2.user.profile_image_url.profile_image_url.xmlText.

Given the n

...
Translate
LEGEND ,
Feb 21, 2010 Feb 21, 2010

Don't look at what's on the rendered output, look at what's in the HTML source the browser is trying to render.

That'll give you a clue as to what's going on.

--

Adam

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
Community Beginner ,
Feb 21, 2010 Feb 21, 2010

sorry for a daft question but how do I do that?

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 ,
Feb 21, 2010 Feb 21, 2010

Depends on the browser.  In Firefox it's right-click anywhere in the main window and select "View Page Source".  In IE it's the same, but "View Source".  All browsers I know of have a similar option.

--

Adam

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
Community Beginner ,
Feb 21, 2010 Feb 21, 2010

Sorry Cameron, I've got it. Just looked at the source of the page through IE and that's what I found:

<img name="" src="<?xml version="1.0" encoding="UTF-8"?>

<profile_image_url>http://s.twimg.com/a/1266605807/images/default_profile_3_normal.png</profile_image_url>" width="44" height="44" style="border:0; float:left" />

So how do I extract the image address itself out of this thing?


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 ,
Feb 21, 2010 Feb 21, 2010

Well, first question: do you want to pass back XML and then need to extract your URL value, or do you just want to pass back the URL by itself in the first place?  There's arguments & use cases both ways.

As to how to extract it, it depends on what the possible content of that XML packet might be.  Is its structure always going to be a single node with just the profile_image_url value?  If so you can just access it directly with result2.user.profile_image_url.profile_image_url.xmlText.

Given the names of your variable there... I suspect you don't actually mean to be passing back an XML packet from that method for the value of the user.profile_image_url subkey.  It looks like you only mean to be passing back the value...?  So fixing that is probably going to be the best approach here.

--

Adam

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
Community Beginner ,
Feb 21, 2010 Feb 21, 2010

cheers Adam, once again you've saved me some on headache pills.

Simon

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 ,
Feb 21, 2010 Feb 21, 2010
LATEST

No worries mate.

--

Adam

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