janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

Large images are missed #95

Closed janboddez closed 9 months ago

janboddez commented 9 months ago

Because they end up in the post content like, e.g., IMG_8432-1024x683.jpg while the corresponding database entry is IMG_8432-scaled.jpg.

janboddez commented 9 months ago

As of WP 5.3, larger images are scaled down (by default, at least). https://make.wordpress.org/core/2019/10/09/introducing-handling-of-big-images-in-wordpress-5-3/

The image metadata contains a original_image but it is near impossible to query for it.

janboddez commented 9 months ago

Alternatively, could use a slightly altered attachment_url_to_postid().

janboddez commented 9 months ago

Not perfect; there might be super rare false positives or something, but ... close enough.

janboddez commented 9 months ago

The alternative would be simply grabbing the IDs from the Image blocks, but that'd only work for block editor posts. Or use their class or something, I think WP adds the attachment ID to images' class attributes. Next time.