Set the image used for social network sharing?

I want to be able to have a different image when people share a topic on social networks. How do I set it per page? Is there a plugin for this?

3 Likes

Sharing uses the first image in the first post of the topic you linked to.

If you link to a post, sharing uses the first image of the first post you linked to.

1 Like

Doesn’t seem that way. For example: https://forum.intercoin.org/t/wall-st-conference-at-mar-a-lago/391/2 and https://twitter.com/IntercoinOrg/status/1090483807067750401

Let’s see

https://forum.intercoin.org/t/wall-st-conference-at-mar-a-lago/391

Looks correct to me. Note that the tweet links to the SECOND post in the topic.

https://forum.intercoin.org/t/wall-st-conference-at-mar-a-lago/391/2

Oh, perhaps because we customized the in the theme, to include some “meta” properties.

But if we didn’t do that, then posts without an image would not get any when shared.

What would be ideal is to have the option to set a default image for all forum pages (or even individual categories!) in some other tab of theme than “Customize CSS” and then override that meta if a topic has an image.

See above answer. The link is wrong.

Wait, let me see one more time. I think what happened was… I edited the theme and commented out the tags when you posted the link. I hope it’s not cached now by this site:

@codinghorror yes, my above comment stands

We had to put meta tags in the theme header so topics without images would have a nice preview. But then every topic has this same image. How do we achieve both with the current software?

I will leave the tags in the theme, so you can reproduce it yourself (post the same link again).

Here’s what it should look like. The site logo will be used for the topic, but the author will be used if you deep link to a post in a topic, like so:

Topic

Post

Yes, that’s good in Discourse but I’m talking about posting links to Discourse topics in Facebook, Twitter and so on.

They don’t do what Discourse does, they show a blank image unless you put those tags. Try it. But once we put those meta tags, now they override everything.

I’m just saying, it would be a great idea for forums to have a field for a default image that is used when posting, but overridden when the topic has a better image. (And if you really want to get fancy, then topics can have one.)

The meta tags I’m talking about are og:image and twitter:card

This isn’t really correct.

For the topic case https://cards-dev.twitter.com/validator shows

For the post case https://cards-dev.twitter.com/validator shows

I tend to agree that we should normalize behavior here, in the first case… when no image exists in the first post, go ahead and use the site logo cc @techAPJ

But note that the link on your twitter refers to a post that does not exist:

https://forum.intercoin.org/t/wall-st-conference-at-mar-a-lago/391/2

There is no post #2 in that topic…

6 Likes

I agree regarding that. Just go to Facebook.com and paste a link to a Discourse post with no images. Is it blank?

My apologies. Just tried it and Facebook seems to have changed its behavior, now it pulls the image correctly when sharing this page.

If I want a large image, though, I would have to somehow set the meta og:image

Anyway… thanks for your attention!

3 Likes

I also wanted to say that I found the settings I was advocating are already in the Settings! Cool!

I like the way this works, and images in social shares are very effective.

However, I find that many first posts in topics don’t include images, so I have to massage my posts on Twitter and Facebook to include an image. This is a) fiddly and b) only benefits my social media shares and not other peoples’

I’d really appreciate a new feature allowing mods/admins to upload an image to assign to a topic for the purposes of social shares.

We could go in and edit people’s posts to include an image, but I have found people can take issue with the content of their posts being edited, understandably so. And they may not understand why their posts are being edited to include an image.

As already stated above, we’re going to change it so the site logo is used for topic links if there are no images in the first post, since that’s how Discourse oneboxes other Discourse instances already, see examples posted earlier in this very topic.

However for deep links to individual posts, the user avatar will still be used if the post does not contain an image.

1 Like

Yes, I can already get this behaviour by setting the default OG image.

However, this isn’t as engaging or topical as an image that’s tailored to the topic in hand.

It would be great for mods/admins to be able to upload and assign an image per topic

Yes, and they can do that by editing the first post, or changing the site’s logo.

This is not on any of our roadmaps for the forseeable future.

3 Likes

No worries. I may see if I can reuse the image upload code from core settings, and the Topic List Previews code that @angus wrote and perhaps I can knock up a plugin to achieve this.

Currently if the topic first post does not have an image we are defaulting to opengraph_image setting. I’ll modify the code to use logo if the opengraph_image setting is blank. So the priority for topic opengraph image will be: first post image > opengraph_image > logo.

5 Likes