wordpress-activitypub icon indicating copy to clipboard operation
wordpress-activitypub copied to clipboard

Featured image removed from link preview after editing post

Open jeremiahlee opened this issue 1 year ago • 10 comments

Quick summary

After editing a WordPress post summary, the preview image changed to a video embed of a linked video from the WordPress post.

Steps to reproduce

  1. I posted a new WordPress post.
  2. I edited the summary because it got cut off with the ellipsis.
  3. On Mastodon, the link preview became was a video embed of https://archive.org/details/p2p-basel-2023-day2/cable-cblgh.mp4 instead of the featured image.
  4. I removed the featured image just to see what would happen.
  5. On Mastodon, the link preview was completely removed.
  6. I added the featured image back.
  7. On Mastodon, the link preview became a video embed again.
  8. I removed the featured image.
  9. On Mastodon, the link preview was completely removed.
  10. I added a different featured image.
  11. On Mastodon, the link preview became a video embed again.

original-post

edit-1-changed-excerpt

edit-2-removed-featured-image

edit-3-added-featured-image-back

edit-4-removed-featured-image-again

edit-5-added-featured-image-back

What you expected to happen

The link preview should remain the featured image.

What actually happened

The link preview changed to a video embed of a video linked from the blog post.

Impact

One

Available workarounds?

No but the platform is still usable

Logs or notes

No response

jeremiahlee avatar Jun 26 '24 13:06 jeremiahlee

The ActivityPub plugin itself does not handle link previews at all. Mastodon uses Open-Graph for that, so you have to check the plugin that generates the Open-Graph data.

pfefferle avatar Jun 26 '24 13:06 pfefferle

🤔 It seems that the site does not use OGP at all... So maybe you should install a plugin for that ;)

See: https://wordpress.org/plugins/opengraph/

pfefferle avatar Jun 26 '24 13:06 pfefferle

Thanks. I now have installed the OpenGraph plugin and confirmed <meta property="og:image" name="og:image" content="https://restoration.software/wp-content/uploads/2024/06/adr1-1.jpg" /> is now present. I updated the post with a featured image again and the link preview has returned to being a failed video embed. 🤷 I understand that must be an oddity of Mastodon's link previewing.

I now realize the difference between this WordPress blog post and my last is that the ActivityPub post for my previous blog post included the featured image as an image attachment. Did this behavior change?

Also, should editing the featured image result in an ActivityPub post edit if it's not getting attached?

old-post

jeremiahlee avatar Jun 26 '24 14:06 jeremiahlee

The plugin should always add the featured image as attachment. Exceptions are, if you use the post-format setting, set the post to video and add a video to the post. In this case the plugin would prefer the video.

pfefferle avatar Jun 26 '24 14:06 pfefferle

I am using the custom post content, but I have not changed the template between blog entries. The setting:

[ap_excerpt]

[ap_permalink type="html"]

[ap_hashtags]

I now see that the original ActivityPub post did actually include the featured image as an image attachment, not a link preview.

Is there any way to inspect if the ActivityPub post is still including the image attachment, but Mastodon is hiding the attached image because its link preview thinks there's a video to embed?

jeremiahlee avatar Jun 26 '24 14:06 jeremiahlee

You can see the JSON, the plugin sends, by adding ?activitypub at the end of each post URL.

pfefferle avatar Jun 26 '24 15:06 pfefferle

Helpful! WordPress is indeed trying to attach a video in the ActivityPub post. I don't know where or how. The only place the attached URL is used is as a link in the post and the link is to a webpage that happens to have a .mp4 extension because that's just how the Internet Archive works.

Any ideas on why that would be getting included as an attachment in the ActivityPub post?

https://restoration.software/posts/adr-1/?activitypub

activitypub-post-json

jeremiahlee avatar Jun 26 '24 15:06 jeremiahlee

THAT is interesting!

I am not sure how this is even possible, will see why this happens!

pfefferle avatar Jun 26 '24 15:06 pfefferle

@jeremiahlee do you use the classic editor or the block editor?

pfefferle avatar Sep 23 '24 09:09 pfefferle

@pfefferle I use the block editor.

jeremiahlee avatar Sep 23 '24 12:09 jeremiahlee

@pfefferle Did something change in the way the plugin processes enclosures since June?

The way the attachment data is structured makes me think it comes from here and somehow made it through all the checks?

"attachment": [
    {
        "url": "https:\/\/archive.org\/details\/p2p-basel-2023-day2\/cable-cblgh.mp4",
        "length": "0",
        "mediaType": "video\/mp4",
        "type": "Video"
    }
],

I've not been able to reproduce it on my test site, even though the video is captured in the post's enclosure custom field.

obenland avatar Dec 04 '24 22:12 obenland

@obenland the enclosure feature was added around that time. for me, the question is more: why is this video added as an enclosure, by WordPress or some other plugin!?!

pfefferle avatar Dec 05 '24 09:12 pfefferle

@pfefferle Not sure what versions of the WordPress plug-ins I had installed when I reported this bug, but here are the plug-ins and versions currently installed:

  • ActivityPub Version 4.3.0
  • Newsletter Version 8.6.4
  • Newsletter - Addons Manager and Support Version 1.3.2
  • Newsletter - Import/Export Version 1.5.6
  • Newsletter - SMTP Addon Version 1.1.4
  • Open Graph Version 2.0.0
  • Plausible Analytics Version 2.1.4
  • WP Super Cache Version 1.12.4

I am not aware of any of these modifying the selection of a featured image.

I can try to update this post and see if it chooses the correct image today to see if it's still a problem. Is it better to do that or to leave it as-is for debugging?

jeremiahlee avatar Dec 05 '24 11:12 jeremiahlee

why is this video added as an enclosure, by WordPress or some other plugin!?!

WordPress automatically scans for it when a post gets published as part of do_pings. It checks for any video or audio links.

The trouble is less with the enclosures themselves, but that it somehow must have made it past this check, that looks for an attachment ID (That's what I assume what happened, still learning the code).

In my testing, trying to reproduce this, I've not been able to find a way to get it into the attachments property, it was always filtered out at the point above.

Aside: Mastodon doesn't seem to need the attachment information to show a preview of the video, a URL in the post seems to be enough.

obenland avatar Dec 05 '24 14:12 obenland

Aside: Mastodon doesn't seem to need the attachment information to show a preview of the video, a URL in the post seems to be enough.

@obenland this is snippet generated using OpenGraph and depends on the OpenGraph/SEO plugin or implementation you use! So this is not the same for every WordPress post or site and we should not rely on it!

See: https://opengraph.dev/panel?url=https%3A%2F%2Farchive.org%2Fdetails%2Fp2p-basel-2023-day2%2Fcable-cblgh.mp4

pfefferle avatar Dec 05 '24 14:12 pfefferle

@obenland there might be one shortcut, if this is used: https://github.com/Automattic/wordpress-activitypub/blob/trunk/integration/class-seriously-simple-podcasting.php

https://github.com/Automattic/wordpress-activitypub/blob/930db56033340a21d876fd46ff5d80b6cb232bee/integration/load.php#L79

@jeremiahlee do you maybe use seriously-simple-podcasting or do you have a defined const SSP_VERSION somewhere in your codebase!?!

pfefferle avatar Dec 05 '24 14:12 pfefferle

@pfefferle Sorry, didn't see the notification of your reply. No, I do not use seriously-simple-podcasting. I have a generic WordPress installation on Hetzner, use the default Twenty Twenty-Four theme, and only the plug-ins listed above. I'm not familiar with SSP_VERSION or where I might check for it.

jeremiahlee avatar Dec 16 '24 19:12 jeremiahlee