• Resolved grayzee

    (@grayzee)


    When you create a flexible content block and then add layouts within it your extension (which is amazing) allows for thumbnails to be assigned.

    How ever these are assigned via the media Library. When I export my ACF Fields from one site and import to another the thumb nail images are lost so I have to spend a great deal of time reassigning these thumb nail images when I either update my theme across multiple domains or do a new install.

    Is there any where I can hard code the thumb nail images via php within the theme to save me from losing them every time I update the ACF fields via import / export.

    Many thanks,

    • This topic was modified 5 years, 5 months ago by grayzee.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey Grayzee,

    This is not in response to your question, but I was just wondering if you are having any issues with the the dynamic preview. I can’t seem to make the preview match the front end. Front end is fine, but the preview is distorted. Seems like it is mainly the fonts.

    Thanks, Rob

    Thread Starter grayzee

    (@grayzee)

    Hi @robswebdev

    I have not really had much luck with the dynamic preview. My themes css is written in sass and compiled on the fly using gulp so it didn’t seem worth using.

    I was planning on writing some php that auto assigns my module images to the wp back end to give some visuals when editing a page. They would how ever be static but would be enough for users to know what blocks they are editing.

    I did think about changing my themes setup so each module had its own gulp setup but never got round to that either.

    Sorry for the not very helpful response.

    Graeme

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello @grayzee,

    You will find filters in the FAQ that will allow you to hardcode thumbnails for each layouts:

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

    You can target specific layout, or even all layouts from specific flexible content fields. Also, remember: you must return an url (relative/absolute) or an attachment ID.

    Hope it helps ??

    Have a good day!

    PS: @robswebdev I’ll answer to your question on your topic.

    Thread Starter grayzee

    (@grayzee)

    PERFECT!!! Thanks for the help, Worked a treat.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I’m glad to hear it! By the way, if you enjoy this plugin, feel free to add a review, it always helps ??

    Have a nice day!

    Regards.

    Sweet lord what a great plugin, and this filter is exactly what I was looking for. Amazing work!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Flexible content – Layout Thumbnails’ is closed to new replies.