Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

og:image #89

Closed
sergio-fonseca opened this issue Jun 19, 2015 · 7 comments
Closed

og:image #89

sergio-fonseca opened this issue Jun 19, 2015 · 7 comments

Comments

@sergio-fonseca
Copy link

sergio-fonseca commented Jun 19, 2015

Hello,

I am trying to setup the featured image as the og:image. How can this be done?
In the facebook debugger I can see the featured image in the post but once I share it, the shared image changes to the blog logo.

Thanks

@LukeTowers
Copy link
Contributor

This would need to be setup within your theme as the og:image tags need to be present within the <head> element of your site's markup.

@stephenkeable-allies
Copy link

@Serge15 this might be late but I had the same issue and used this code to pass the image to the template:-

function onEnd() {
    $_post = $this->components['blogPost'];
    if ($_post->featured_images->first()) {
        $this->page->og_image = $_post->featured_images->first()->path;
    }
}

Which will allow you to use this markup in your template:-

{% if this.page.og_image %}
     <meta property="og:image" content="{{ this.page.og_image }}" />
{% else %}

@Hessel91
Copy link

This ain't working anymore, anyone who has a better solution?

@LukeTowers
Copy link
Contributor

Got an explanation of how it ain't working anymore @Hessel91?

@Hessel91
Copy link

Hessel91 commented Jan 16, 2019

Well I get this error when I add the code to the blog post page.
I used {% if this.page.og_image %} <meta property="og:image" content="{{ this.page.og_image }}" /> {% else %} inside the head of my theme.

@LukeTowers
Copy link
Contributor

That's because of an error in your code. $_post = $this->components['blogPost'] is the component object, not the post object. Do $_post = $this->components['blogPost']->post instead.

@Hessel91
Copy link

Thank you Luke for notice. It works perfectly now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants