joppuyo / acf-image-aspect-ratio-crop

Image Aspect Ratio Crop field for Advanced Custom Fields
https://wordpress.org/plugins/acf-image-aspect-ratio-crop/
GNU General Public License v2.0
106 stars 16 forks source link

Add integration code for BB Toolbox #49

Open danieliser opened 3 years ago

danieliser commented 3 years ago

The following for me made this field work perfectly in Beaver Builder along side the BB Toolbox plugin you recommend.

But without this it does not work.

Maybe consider adding this to the plugin so it just works out of the box?

add_filter( 'toolbox/helpers/settings/type=image_aspect_ratio_crop' , 'toolboxConnectors_acf::settings_image', 10, 2 );
add_filter( 'toolbox/helpers/sc_attr/type=image_aspect_ratio_crop' , 'toolbox_acf::return_shortcode_attr_default_image' , 10, 1 );
add_filter( 'toolbox/helpers/get_acf_field/type=image_aspect_ratio_crop' , 'toolbox_acf::acf_return_image' , 10, 5 );
add_filter( 'toolbox/helpers/get_acf_field/type=image_aspect_ratio_crop' , 'toolbox_acf::acf_return_image_failsafe' , 10, 5 );
add_filter( 'toolbox/helpers/get_acf_field/type=image_aspect_ratio_crop' , 'toolbox_acf::post_object_to_array' , 10, 5 );
add_filter( 'toolbox/helpers/get_acf_field/type=image_aspect_ratio_crop' , 'bb_toolbox_display_image_aspect_ratio_crop' , 10, 5 );

/**
 * Default behavior for the Youtubepicker fieldtype
 * @param  mixed  $string       [passed in value/string/array/object]
 * @param  array  $field_object [this fields field_object]
 * @param  mixed  $value        [this fields returned_value]
 * @param  array  $atts         [shortcode attributes or users settings]
 * @param  int    $postid       [postid to query]
 * @return mixed                [returned value for next callback or output]
 */
function bb_toolbox_display_image_aspect_ratio_crop( $string , $field_object , $value , $atts = null , $postid = null ) {
    $size = $atts['size'];
    $fullsize = $value['url'];
    $selectedSize = isset( $value['sizes'][ $size ] ) ? $value['sizes'][ $size ] : $fullsize;

    return $selectedSize;
}
joppuyo commented 3 years ago

Hey, thanks for the code, I think I will add this to the documentation for people using this plugin with Beaver Builder.

Unfortunately, I don’t think it’s a good idea to add this code to the plugin since it would imply that I support Beaver Builder out of the box which I do not.

I’m not a Beaver Builder user and that’s why I can’t give any support related to it. I think it would be better if someone with Beaver Builder experience would maintain that code.

Sorry if I sounded harsh but it’s the same situation with Elementor. This plugin uses standard ACF API and it would be up to third-party developers to support 3rd party ACF fields in their plugins which Beaver Builder and Elementor do not.

I don’t mind people using either of these plugins but I can’t offer any support because of the above-mentioned reasons.

joppuyo commented 3 years ago

If you are interested in creating a Beaver Builder + Toolbox + Aspect Ratio Crop integration, I would suggest wrapping up this code in a plugin and releasing it on GitHub.

This way people will be able to get updated code if there are any changes to BB / Toolbox in the future.

I can then provide a link in the plugin FAQ for Beaver Builder users.