Solved

Cold Fusion Meta Tag and Open Graph

Posted on 2013-06-18
8
762 Views
Last Modified: 2013-06-19
Hi,
I'm having an issue with Facebook not pulling the correct photos to use as a thumbnail when someone shares one of the dynamic pages on my site.
I read on the FB site that I should use Open Graph (og) tags in a meta tag on my site.
So that's what I tried to do.
<cfset photoext =".jpg">            
<cfset finalphoto = #ID_Number# & photoext>
      
      <meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />

However, whenever I check any of my pages using the Facebook debugger:
https://developers.facebook.com/tools/debug

It appears as though Facebook is not seeing the resolved value of #finalphoto# because the URL is says it scraped is:
http://www.mysite.com/site-data/photos/property/1/#finalphoto#
and not
http://www.mysite.com/site-data/photos/property/1/myphoto.jpg

If I hard code in a photo name in the meta tag then FB sees it just fine.
      <meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/hardcodephoto.jpg />

I created a log file using <cffile> and write the value of the meta tag to the log file and see that the generated URL/photo is completely valid.
I am not understanding why the value of #finalphoto# isn't being resolved by the facebook scraper.
Anyone have any ideas?

Thanks,
N
0
Comment
Question by:nachtmsk
  • 3
  • 3
  • 2
8 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
I'm not familiar w/the FB debugger...  

As silly as it sounds, the only thing I can think of is that maybe you forgot to wrap the <meta> tag in a cfoutput, so the #finalphoto# variable is never evaluated. That's why FB sees "#finalphoto#" instead of "myphoto.jpg".


<cfset photoext =".jpg">            
<cfset finalphoto = ID_Number & photoext>
<cfoutput>      
      <meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />
</cfoutput>
0
 

Author Comment

by:nachtmsk
Comment Utility
Hi agx
The meta tags need to be in the HEAD element. I don't think I did wrap it in a cfoutput. Wondering if I can put a cfoutput tag in the HEAD element. I'll try and report back! Thanks!
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
(Edit) Sure, you can use cfoutput anywhere.  It runs on the server, so the browser never even sees it. All it'll do is cause your #variable# to be evaluated, turning this HTML string:

<meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />

... into this:

<meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/myphoto.jpg" />
0
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
As a matter of fact, you can use  <cfhtmlhead> tag to create the meta tag,

Here is simple usage example.

<cfset photoext =".jpg">            
<cfset finalphoto = "YourPhoto" & photoext>

<h1>Thank You</h1>
<div>All of your coldfusion and html code goes here!</div>

<!--- Save the headcontent --->
<!--- This code can appear anywhere within your page --->
<cfsavecontent variable="headContent">
<cfoutput>
<meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />
</cfoutput>      
</cfsavecontent>

<!--- Add the head content --->
<!---
Use this tag for embedding JavaScript/other HTML tags, such as meta, link, title, or base in an HTML page header
--->
<cfhtmlhead text="#headContent#"/>
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Yeah, but the real problem had nothing to do with headers.  He just forgot the cfoutput tags.  You must use cfoutput tags to display the value of a variable, simple as that. Omit it and you just get literal code.

Test Code
        <cfset yourVariable = "FOO">
        no cfoutput: #yourVariable#
        with cfoutput <cfoutput>#yourVariable</cfoutput>

Output/Result


        no cfoutput: #yourVariable#
        with cfoutput: FOO
0
 

Author Comment

by:nachtmsk
Comment Utility
Ugh.. can't believe I forgot the <cfoutput> tags . It was driving me nuts for a few hours.
Working fine now.
Thanks everyone!
Nacht
0
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
What I was showing is a way to handle the content that should go inside a <head></head>
tag.
0
 

Author Comment

by:nachtmsk
Comment Utility
Thanks Pravinasar. It's good to know how to handle that. I should have given you some points too, sorry.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now