[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Cold Fusion Meta Tag and Open Graph

Posted on 2013-06-18
8
Medium Priority
?
807 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

656 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