?
Solved

Cold Fusion Meta Tag and Open Graph

Posted on 2013-06-18
8
Medium Priority
?
796 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 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
 
LVL 1

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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
LVL 29

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
 
LVL 1

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 29

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
 
LVL 1

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

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
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 …
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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