Support » Plugin: Advanced Custom Fields: Extended » Get flexible field preview image from some custom url instead of uploads?

  • Resolved joelalexandersson

    (@joelalexandersson)


    Hi! I like the feature where you can get add a preview image for a flexible layout but I don’t like the fact that I have to upload these images to be visible in the media section for my clients to delete. Is there some way to get those images from somewhere else or maybe even hide them or something like that?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    Absolutely, you can change the Flexible Content Layouts Thumbnails programmatically using the acfe/flexible/thumbnail filter. Usage example:

    add_filter('acfe/flexible/thumbnail/layout=my_layout', 'my_acf_layout_thumbnail', 10, 3);
    function my_acf_layout_thumbnail($thumbnail, $field, $layout){
    
        // Must return an URL or Attachment ID
        return 'https://www.example.com/my-image.jpg';
    
    }
    

    You’ll find more details in the documentation.

    Hope it helps,

    Have a nice day.

    Regards.

    Thread Starter joelalexandersson

    (@joelalexandersson)

    Yes! Perfect. Thank you so much! One thing. How do I make multiple filters for this? Do I need to make a unique function for each layout?

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    You can either create multiple filters/functions for each layouts using acfe/flexible/thumbnail/layout=my_layout or create a wildcard filter for a specific Flexible Content field using acfe/flexible/thumbnail/name=my_flexible and add if/elseif conditions based on data in $layout within the function.

    You’ll find all hooks variations in the documentation.

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.