Facebook Open graph tags for blogger - OG Image is too small. Can I designate full size image instead of thumbnail?

不想你离开。 提交于 2019-12-01 20:47:45

I know this is an old question (2 years ago), but I hope my answer can help other peoples when they are looking for a solution.

Currently, we are using this code to create thumbnail when sharing links on Facebook:

<meta expr:content='data:blog.postImageThumbnailUrl' property='og:image'/>

And Blogspot will generate the HTML code looks like this:

<meta property="og:image" content="http://1.bp.blogspot.com/-t5-HTAnnThU/Vicp0SSNPeI/AAAAAAAACZw/9lbrjwRY64A/s72-c/get-free-xyz-domain.png" />

Yes, as you said, it is a 72x72 image. But did you know that we can change the image size based on the image URL?

When you replace s72-c to w600-h315-c (600x315):

Now, the problem is how we can replace the new link? I used the following tricks:

<meta expr:content='"http://junookyo.freevnn.com/?img=" + data:blog.postImageThumbnailUrl' property='og:image'/>

And here is the simple PHP code:

<?php

if (isset($_GET['img']) && filter_var($_GET['img'], FILTER_VALIDATE_URL)) {

    $img = $_GET['img'];

    if (strpos($img, '/s72-c/') !== FALSE) {

        $img = str_replace('/s72-c/', '/w600-h315-c/', $img);

        header("Location: {$img}");

    }

}

exit;

The final result:

Read my blog post for more details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!