jameelmoses / acf-flexible-content-extended

Extends the ACF Flexible Content Field by transforming the layout list into a modal with image previews. Editing the fields layouts also happens in a modal for a better editing user experience.
Other
22 stars 9 forks source link

Add filter allowing change to the default file extension expected #25

Open benvoynick opened 10 months ago

benvoynick commented 10 months ago

This PR adds a hook to change the file format expected by the plugin in its search for images. This can address issue #19 as well as any other format someone would care to use for a site.

Warface commented 1 month ago

Nice work. I've made some change in the main.php so you can put an array of extension instead and load jpg,png and webp.

` $extensions = ['jpg', 'png', 'webp'];

// Loop through each extension to check if the image exists
foreach ( $extensions as $ext ) {
    $image_path = get_stylesheet_directory() . '/' . $path . '/' . $layout . '.' . $ext;
    $image_uri = get_stylesheet_directory_uri() . '/' . $path . '/' . $layout . '.' . $ext;

    // Check if the image exists for the current extension
    if ( is_file( $image_path ) ) {
        return $image_uri;
    }
}`