• Hello,

    I was wondering if there is a way to share a post (article+featured image) which featured image isn’t on my website?

    I have tried few times and all I see in FB was the text (link) with an empty (white) square box.

    Here is a picture:

    View post on imgur.com

    The thing is that I have over 150 posts a day on that website and if I host the images on my server I will run out of space in few months. But I can’t share the posts on FB or Twitter properly as they are without images.

    I am currently using a plugin called NELIO CONTENT for the external images.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter snipsnip

    (@snipsnip)

    Inferred Property
    The ‘og:image’ property should be explicitly provided, even if a value can be inferred from other tags.

    This is what facebug sharing debugger tells me

    Moderator bcworkz

    (@bcworkz)

    og:image is normally supplied in the head section as a meta tag. For example:
    <meta property="og:image" content="//imgur.com/whatever-path/post-image.jpg">

    In fact, the entire FB share can be defined with OG tags. See https://developers.facebook.com/docs/sharing/webmasters#markup

    There’s no mention that I saw requiring the image URL to be on the same server as the post.

    You can insert OG tags in the head section by hooking the “wp_head” action and echoing out whatever HTML content you need. Use is_single() to only output these tags for single posts. You can get the queried post object from $GLOBALS['post'].

    How you get the image URL is variable, depending on how it was established to start with. Getting a featured image URL is simple enough. If the post only includes one attached image, there are ways to get the URL from attachment posts. The method of last resort, which is what you probably need to do, is parse the post content, looking for an img tag. Once found, the URL can be extracted from the src attribute. preg_match() is useful for this kind of searching. If you want the first img tag encountered, the process is straight forward. If you need the image URL that’s not the first, it gets more complicated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sharing external Images from WP to FB?’ is closed to new replies.