Solved

Cold Fusion Meta Tag and Open Graph

Posted on 2013-06-18
8
779 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
ID: 39257408
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
ID: 39257682
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_
ID: 39257754
(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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 28

Expert Comment

by:Pravin Asar
ID: 39257874
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39257910
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
ID: 39257926
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
ID: 39259176
What I was showing is a way to handle the content that should go inside a <head></head>
tag.
0
 

Author Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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