When a user shares content from my website, often the image appearing in the thumbnail is the logo of the website instead of the image itself.
How can I tell reddit to ignore the logo ?
I searched a lot and found answers on how to specify which image reddit should use with the og image
meta tag, but I can't do that since my website is part UGC, meaning I wouldn't know what is the absolute URL for every image.
For example: reddit not pulling scraping image on link post
EDIT:
This doesn't seem to be working on my end. Does it work on yours ?
<script>
function img_find() {
var imgs = document.getElementsByTagName("img");
var imgSrcs = [];
for (var i = 0; i < imgs.length; i++) {
imgSrcs.push(imgs[i].src);
}
return imgSrcs;
}var result = img_find();
$("meta[property='og:image']").attr("content", result[1]);
</script>
Your code
$("meta[property='og:image']").attr("content", result[1]);
is almost the solution. Let's do the last step:
$("meta[property='og:image']")
.attr("content", $('css_selector_of_the_img')[0].src);
So what is css_selector_of_the_img
? Since you have the website logo, I'd assume that you had some HTML around your image. Probably the image has a className or placed into a container e.g. css_selector_of_the_img
could be div.content img
or img.uploaded
whatever. And throw away your img_find function J.
I found the solution.
Adding property="og:image"
to the <img>
I want selected worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With