Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Fails in what way?

    From the plugin code:

    $video_thumbnail_url = $file_headers[0] !== 'HTTP/1.0 404 Not Found' ? 'https://img.youtube.com/vi/' . $youtube_id . '/maxresdefault.jpg' : 'https://img.youtube.com/vi/' . $youtube_id . '/hqdefault.jpg';

    It’ll fall back if making the request to maxresdefault returns a 404 error. However, at least with the provided video, this is technically a valid image and not a 404 error:

    https://img.youtube.com/vi/sUSknJSDiME/maxresdefault.jpg

    Not something we’re going to be able to control on our end, as that all comes from YouTube itself. I am curious if there’s a way to request regenerated thumbnails from them at all.

    Thread Starter Gerald

    (@gerital)

    The problem was that allow_url_fopen was disabled in PHP. Setting it to “1” made your code work perfectly for the mentioned video thumbnail.

    Actually you are right about the 404 error it detects so your line of code gives the desired result and I can automatically retrieve the image from hqdefault.jpg

    Thanks for your help!

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Interesting. Good to hear you got it figured out. Not something we’d be able to control very well on our end admittedly.

    Thread Starter Gerald

    (@gerital)

    Maybe it would be good to give a warning in the case allow_url_fopen is disabled? In this case get_headers() doesn’t work and there is no way to decide if grabbing hqdefault image.

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Added an issue to the GitHub repo for this plugin. https://github.com/WebDevStudios/Automatic-Featured-Images-from-Videos/issues/12

    In short, I think we on our side should not use get_headers() directly, and instead use wp_remote_head() from WordPress core. I think that function would have fallen back to a different HTTP method that was available on your hosting, instead of requiring you to tweak your PHP settings manually.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Featured image not showing up for HQ/HD videos’ is closed to new replies.