Ignore favicon, use default open graph image to create og:image tags


(Arnold Schrijver) #1

I have posted forum topics a number of times before on LinkedIn, and always this worked perfectly. A link image was retrieved (in my case showing the Humane Tech frontpage image).

But I just posted to LinkedIn and the image stayed blank. While this may not indicate a bug in Discourse (after all on LinkedIn things are continuously breaking, or behaving oddly), there may be some possible fix in Discourse that has the image show up again.

The LI post URL is:

And the forum post that this points to is:

If you think this is a LI issue, then I will create a support case there…

This is the image that was shown before:

It is not in the open graph metadata of the topic page, but it exists on the Humane Tech website.

According to LinkedIn, having the og:image tag present should do the trick. So this would imply that previously this was available in the Discourse html source for the topic.

Note: I just created a cross-reference to this topic from our Moderators group, but that also does not show the Discourse logo in the link preview.


No open graph link previews for Mozilla and Firefox URL's
(Robert McIntosh) #2

As a matter of interest, have you added a link to the default opengraph image url setting?


(Arnold Schrijver) #3

Thank you for that hint, @robmc!

This field was indeed empty. So I have added the link there, and will now fix LI post.

But what I find strange is that before this always worked for us, and suddenly it is not. AFAIK no other mods/admins have made changes. Is this a new setting, or where there changes that may have cleared the setting?


(Arnold Schrijver) #4

Hmm, but now to get that URL to be used.

I searched a bunch of meta topics on how to upload. I have tried providing an external link, not working, then to upload an asset to the Default theme and use that as open graph, which didn’t work. Then I found a topic that said I should upload to the staff topic ‘Assets for the site design’, which I did , but setting the upload URL still does not give me an Open Graph image.

When I do an Open Graph check it shows the Wordpress icon is used. This comes somewhere from default Discourse setting, but not from our settings. There are uploads references in our settings that seem not to be used, like the favicon url (don’t know where I can find the source of these uploads, also)


(Robert McIntosh) #5

First thing, it may not be immediate for the site to fetch the new image - I am not sure off the top of my head whether this happens directly or part of a routine (my colleagues are travelling at the moment so I will get back to you on this)

Secondly, if you are testing the OG, then (after waiting for the above) you may need to ensure they clear any cached versions of the OG info for your domain, then test again.

The URL path can be any you want but if you need to add a new image specifically, then yes, the site assets works fine.

I am not 100% certain that this is the issue that will fix LinkedIn but I know that the OG image has been added to give a better fall-back option should it not locate an image as part of the normal process. LI has been making lots of changes to their interface and this could be part of that instead.


(Arnold Schrijver) #6

I think there is some routine that should occur, as the current og tags are still:

<meta name="twitter:image" content="https://s1.wp.com/i/favicon.ico" />
<meta property="og:image" content="https://s1.wp.com/i/favicon.ico" />

I’ll wait for a while, and then try again. Thank you for your help Robert!


(Arnold Schrijver) #7

I just remembered some other functionality in how og:image meta tags are created on Discourse: If a topic/post has a link preview on it, then the og:image is derived from this URL.

I think this is a cool feature, in principle, but it does not seem to work properly in this case.

My first link preview in my topic is to:

And I think the Wordpress icon is coming from there, even though this site has a different og:image in its metadata, that points to https://matthewdgreen.files.wordpress.com/2018/09/untitled-3.png


(Arnold Schrijver) #8

I can confirm that this is the case. When replacing the link preview with a regular link, the og:image contained the image from the 2nd link preview in my post. When removing that one, it did not change to the default Humane Tech open graph image, but kept the last image.

And testing on LinkedIn. It does not seem to work. LinkedIn still does not give me a preview image when sharing.

Edit: I asked a question on this in the LI forum: Open graph tags present, but preview image still not displayed | LinkedIn Help Forum


(Robert McIntosh) #9

To be honest, it looks like there is something amiss on your blog setup

It seems that Discourse renders the image fine, but if you test the blog post with iFramely there are some odd results. You might want to search there before changing too many things on Discourse


(Arnold Schrijver) #10

The result that is shown is actually correct after the edits I made (sort of). The ‘Signed-in Chrome mode’ comes from the og:image in the second link that used to have a link preview.

Since my post does not have link previews anymore I expected the og:image to fall back to the default specified in Settings, but it kept the image from the last link preview that I removed.

Also, this image has once again changed, and on iFramely it is now showing a different image than the one you posted. But this is the one I actually wanted. BTW, I test open graph with https://opengraphcheck.com/

The image now shown is as below, and coming from this link:

Still LI is not showing this.


(Arnold Schrijver) #11

I am not sure what is the exact problem, but in the end the Discourse post has the right og:image, so I assume the issue is at LinkedIn.

I have finally decided to post without the preview image. Thank you for your help!! I’ll mark resolved.


(Arnold Schrijver) #13

I was still working with LinkedIn on a Support Case, and they asked me to test again (after generating a preview they require 48 hrs before retrying, to ensure their cache is cleared).

On LinkedIn the preview generation now works (takes image from og:image in discourse topic page), but I noticed something else:

Consider this topic: Personal data as currency - Privacy - Humane Tech Community

You see the nice onebox preview image on the NPR.org link:


.

But the og:image meta element in the page source has this image instead:
og:image contents

Which looks really bad when sharing on LinkedIn or other places, because it is enlarged so much that it looks low-res.

I’d expect the first image to end up on the og:image.


(Robert McIntosh) #14

I think I see what you are saying now - and this should probably be classed as a Feature request rather than support

What I think we are saying is that Onebox works fine. If you take a link from another site that is configured correctly, then you get an attractive preview with the correct image, such as this:

What happens is that the topic in Discourse uses the first image it find as its og:image reference. If there is no other image included in the OP but there is a oneboxed link, that first image will be the favicon rather than the oneboxed ‘featured’ image.

When you share the link to the topic to another site (whether Discourse, LInkedIn, or others) then the image used is the favicon, like this:

So what would fix this would be to ignore favicon images when creating og:image tags (maybe use the site’s default opengraph image url instead). Is this correct?


(Arnold Schrijver) #15

Yes, exactly. Thanks for your elaborate reaction!

The first issue I had on LinkedIn did not show any preview image, because og:image contained the Wordpress ICO favicon, which is not a supported image format at LinkedIn. After editing the message I did not see a change on LI, because it may take 48 hrs for the cache to be cleared. (Which led to a lot of troubleshooting, because I did not know that).


(Arnold Schrijver) #16

I just renamed the topic and made it a feature request.


(Sam Saffron) #17

@techAPJ did we not have a bunch of discussion previously about this, I recall us playing with the defaults here at least once before.


(Arnold Schrijver) #18

Would like to read those. Wonder what the reason is to not use the Open Graph that already exists in the site, to build the Onebox link preview.

Maybe this is a bug instead of a feature request?
I bump into the issue quite often. Just now with Termly, that has full open graph info:

https://termly.io/privacy-policy/privacy-policy-generator/


(Jeff Atwood) #19

Sorry @aschrijver what is the problem? I think Rob correctly answered your question. Make sure the linked topic (or post) has a large image in it near the top (if not at the top) and you should be fine.


(Arnold Schrijver) #20

Oops, @codinghorror this is my bad. I mixed up 2 topics. The termly.io issue should be part of No open graph link previews for Mozilla and Firefox URL’s. and now that I ‘unmix’, this is probably another case where the Onebox User-Agent was blocked.

Sorry for the confusion.


(Arpit Jalan) #21

This topic (linked post in particular) has lots of info about how we handle opengraph image tags: