acf-extended / ACF-Extended

🚀 All-in-one enhancement suite that improves WordPress & Advanced Custom Fields
https://www.acf-extended.com
239 stars 27 forks source link

Flexible content thumbnails can have remote images #67

Closed DevWael closed 3 years ago

DevWael commented 3 years ago

:memo: Description

The flexible field became an awesome field after the ACF-Extended plugin but when it comes to creating a theme and making a theme home page builder using this field type, you will need to host the assets of the sections you have created with the flexible content field. then we need to have the option to set the URL of the image instead of uploading it to the website.

:gem: Type of change

acf-extended commented 3 years ago

Hello @DevWael,

Thanks for the feedback and the pull request! However, I cannot accept it since it will change the Image field type to text, and break compatibility with all other users which already use Image Upload.

FYI, you can already use an Image URL using the following hooks available in the plugin's FAQ:

// 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/thumbnail/name=my_flexible&layout=my_layout',  'acf_flexible_layout_thumbnail', 10, 3);
// add_filter('acfe/flexible/thumbnail/key=field_xxxxxx&layout=my_layout',  'acf_flexible_layout_thumbnail', 10, 3);

add_filter('acfe/flexible/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';

}

Have a nice day!

Regards.