WebDevStudios / Automatic-Featured-Images-from-Videos

If a YouTube or Vimeo video exists in the first few paragraphs of a post, automatically set the post's featured image to that vidoe's thumbnail.
33 stars 24 forks source link

Featured image duplicated ad nauseam #6

Closed ozh closed 6 years ago

ozh commented 9 years ago

Hi team

One little bug with this plugin: every time you update a post without changing the Youtube video, it recreates another featured image with the same Youtube screenshot.

A simple workaround would be to store the video URL in metadata after creating the image the first time, and when the post is saved/updated, check if there's already a metadata with that URL.

Cheers!

Ozh

bradp commented 9 years ago

That's odd, as it shouldn't do anything if a featured image already exists, as we bail out early if it exists. https://github.com/WebDevStudios/Automatic-Featured-Images-from-Videos/blob/master/automatic-featured-images-from-videos.php#L45

Is this on a published post or a draft?

bradp commented 9 years ago

Actually, I see the issue.

Every other time it will recreate it, as we set meta to false for _is_video

https://github.com/WebDevStudios/Automatic-Featured-Images-from-Videos/blob/master/automatic-featured-images-from-videos.php#L53

This should be a simple fix.

jtsternberg commented 9 years ago

What about the scenario where this plugin adds the featured image automatically, then the user removes it. The next time it's saved, the process starts over (and a new version is uploaded).

ozh commented 9 years ago

I'm experiencing the problem on scheduled posts but I'm not sure that's related. I think I've seen it on published posts too.

As I see it (emphasis on "I", maybe the plugin wasn't created with that in mind), the plugin should :

tw2113 commented 8 years ago

Related #20

tw2113 commented 6 years ago

Going to start adding video IDs to the title and thus also the GUID column. We'll then do a sql LIKE query for that video ID value and assign that attachment ID as the featured image if one is found.