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

    (@tw2113)

    The BenchPresser

    Hi Deyson, I was going to say “not really” but I decided to look over the plugin code first anyway, and found this little nugget:

    // allow developers to filter the content to allow for searching in postmeta or other places
    $content = apply_filters( 'wds_featured_images_from_video_filter_content', $content );

    You could replace the returned $content variable with your custom field data from ACF and make sure the youtube/vimeo url is in the returned value
    to be parsed out via regex.

    After that, if I’m reading the code properly, it will do the rest automagically for you.

    Thread Starter deyson

    (@deyson)

    Ok thank you I will give it a try. ??

    Hi Michael and Deyson,

    that sounds great, however, could you elaborate on how to actually use your nugget? Let’s say I have an HTML-filled field ‘media’ for my posts that contains the YouTube URL, how would I make your plugin search this field?

    // allow developers to filter the content to allow for searching in postmeta or other places
    $media_field = get_field('media');
    $content = apply_filters( 'wds_featured_images_from_video_filter_content', $media_field );

    does not look right to me :-/. Thanks in advance!

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    function physalis_fetch_youtube_image( $content ) {
        $media_field = get_field( 'media' );
        if ( ! empty( $media_field ) ) {
            return $media_field;
        }
    
        return $content;
    }
    add_filter( 'wds_featured_images_from_video_filter_content', 'physalis_fetch_youtube_image' );

    In this filter, we fetch the media field you want, and if we have something to return, we return that, if we do not, we just return the original value. Basically passing back the $media_field value to be searched instead of the original. You’d want to place this in your functions.php file for your current theme, or in a custom plugin if it needs to not be theme-dependent.

    Woah, thank you so much!

    However, one more basic question – how exactly does this plugin work? What image size does it fetch, and does it include already published posts? Or how would I make it work? Does it automatically fill empty post_thumbnail fields?

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looks like it checks for the maxresdefault image size from YouTube, and if that doesn’t exist, it moves to hqdefault.

    It doesn’t recursively do its thing for all existing posts, you have to trigger it by editing and then saving a post.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Advanced Custom Fields compatibility.’ is closed to new replies.