Code Monkey home page Code Monkey logo

acf-image-aspect-ratio-crop's Issues

Add integration code for BB Toolbox

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;
}

Cropping is not working after the update

Hello,

After the last updates when i try to crop, I receive the error: Failed to crop image
On the console i see the another error:
/wp-json/aiarc/v1/crop:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Display image cropper when using basic file selector

There is an issue when a user does not have access to the media library but can create posts with a field group with an Image Aspect Ratio Crop field.
When such a user creates a post, ACF skips the media library and simply provides a default file selector for the image field. In this case the cropper is skipped and it is not possible to save the image.

Could it be possible to add the image cropper in this scenario and allow the saving and cropping for these users?

Disable thumbnail generation for cropped images

Wordpress generates thumbnails for downloaded images (150x150). And I do not disable this feature because it is responsible for displaying thumbnails in the media library.

But thumbnails are also generated for cropped images, and they take up disk space, but are not used, which is not very good.

It would be great if there was an option to disable creating copies of cropped images.

Dependabot warning: Axios

I've got the acf image aspect ratio crop plugin in a github repo for a project, and I'm receiving a Dependabot warning about a security issue with Axios.

Screen Shot 2021-04-20 at 12 36 27 PM

Do "Width" and "Height" settings have to be required?

With version 3.2 the "Width" and "Height" settings became required. Before that I used the plugin for aspect cropping and also just for image fields with a cropping option. I achieved that by not using the width and height options. Is there a special reason they are required now?

I would propose to have a third crop type option: "Free cropping" which just gives the user the cropping window without any predefined crop ratio. The width and height options could be hidden when that option is choosen.

Please let me know what you think about that. I could also start a pull request.

Cheers!
Phil

Hiding sale category from shop page

Hello! I am trying to hide the sale category from my shop page. I have tried adding the code below to functions.php (from this page: https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/), but it hasn't worked for me so far. Am I missing something?

/**

  • Exclude products from a particular category on the shop page
    */
    function custom_pre_get_posts_query( $q ) {

    $tax_query = (array) $q->get( 'tax_query' );

    $tax_query[] = array(
    'taxonomy' => 'product_cat',
    'field' => 'slug',
    'terms' => array( 'sale' ), // Don't display products in the sale category on the shop page.
    'operator' => 'NOT IN'
    );

    $q->set( 'tax_query', $tax_query );

}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

Remote URL crop

If original image is not found in the file system, fall back to fetching image from URL. This is helpful if using a plugin like Offload Media which stores media gallery in S3.

Make min/max height and width work in a sensible way

Right now these apply only to the original image and not the cropped image since this functionality is derived from the normal image field. The current plan is:

Aspect ratio crop:

  • Set when entering width or height, calculate the other value automatically according to aspect ratio.
  • Crop area cannot be smaller than min values
  • Crop area can be larger than max values but the image will be resized to max values after cropping

Pixel size:

  • Min size works already in the correct way
  • Do we need a max size? I could probably be removed since the image is resized anyway to pixel size

Free crop:

  • I have no idea how this should work. Is it really "free" if there are min/max sizes?
  • Remove min and max fields completely?

Filtering Image-Array

Awesome plugin. Love it! Is there a buy me a coffee link somewhere?

Also, is there a filter to slim down what is returned from the original image array? And maybe even what is returned from the images array if set Image-Array? Or would you suggest another method?

Verbose debugging - post data in my logs

Going through a client's PHP error logs I kept seeing large dumps of data that seemed to be entire post objects printed to error_log() but couldn't figure out if I left some code in a plugin or theme I developed.

I eventually came across these calls to the debug() method adding the the save_post ACF action:

add_action(
    'acf/save_post',
    function ($post_id) {
        $this->debug('post_id');
        $this->debug($post_id);
        $this->debug('POST');
        $this->debug($_POST);
       // [...]
    }
);

And seeing the debug function is defined as:

function debug($message)
{
    if (defined('WP_DEBUG') && WP_DEBUG === true) {
        error_log(print_r($message, true));
    }
}

I can see how this would easily be an issue. I'm not sure why anyone using this plugin would want their PHP error logs filled with debug info of this verbosity but using the WP_DEBUG constant seems like a pretty bad idea to me. Perhaps an option to enable verbose debugging in the plugin would be more useful?

Woocommerce

Is it possible to use it in a woocommerce? In product page with add to cart?

Metadata under original_image

I know we have access to the original metadata under the original_image, but it would be nice if alt text, title and captions specifically could be copied over to the new image. Thoughts?

Theme integration

Both acf and acf-extended offer the possibility to integrate them in a theme. Is there a proper way of doing this with acf-image-aspect-ratio-crop as well? I know about the pros and cons of doing so in general but for my usecase it would be big benefit.
Thank you in advance :)

wpml_sync_all_custom_fields action

Hello, thanks for the nice plugin.

My goal is to copy the alt text of the original image to the new cropped image. I found the wpml_sync_all_custom_fields action called at the end of the create_crop function, and I'm using it to do this:

add_action( 'wpml_sync_all_custom_fields', 'dt_aiarc_copy_alt');
function dt_aiarc_copy_alt( $attachment_id ) { 
 
  // only proceed if this is an image
  if (!wp_attachment_is_image($attachment_id)){
    return;
  }

  // get image meta
  $img_meta = get_post_meta($attachment_id);
  
  // if this image has an "aiarc" original, but does not have alt text
  if ( isset($img_meta['acf_image_aspect_ratio_crop_original_image_id']) && !isset($img_meta['_wp_attachment_image_alt'])){

    // get original image
    $original_image = get_post_meta($img_meta['acf_image_aspect_ratio_crop_original_image_id'][0]);

    // if original image has alt text...
    if ( isset($original_image['_wp_attachment_image_alt']) ){
      
      // copy the original's alt text to the cropped image
      add_post_meta( $attachment_id, '_wp_attachment_image_alt', $original_image['_wp_attachment_image_alt'][0] );
    
    }

  }
 
}

This is working OK but I have some questions.

  • I realize wpml_sync_all_custom_fields is related to the WPML plugin but I don't fully understand what it does. Could this cause problems on a site with WPML installed?
  • Is there a better way to do this (copy alt text from original image)?
  • If not, any chance this feature will be added in the future as a field setting?

Copy Link field when editing a page/post initially shows misleading image file name

I think this is just an enhancement request to help a user understand what's going on. I thought there was an issue with the plugin, but there isn't.

  1. Upload an image with correct aspect ratio into an ACF aspect ratio crop field. Image should already cropped correctly based on the settings (e.g. file name "Image.jpg")
  2. In the crop screen, click "Crop" (even though we don't need to crop since the aspect ratio is already met)
  3. Once uploaded, click on the Edit button on the image. Note that the "Copy Link" field lists the image name as "Image-150x150.jpg". This is where I was getting confused because I thought the crop functionality wasn't respecting my aspect ratio settings and it was instead cropping to 150x150
  4. Save draft or publish the page
  5. Click on the Edit button on the image. Note that the "Copy Link" field now lists the correct image name "Image.jpg"

Activation hook should create option with autoload yes

Hi, I have no option "acf-image-aspect-ratio-crop-settings" in DB after activation plugin. This is bad, because on every load page plugin look to this option and there is additional SQL query. If you save default option to DB with autoload=yes, it will be ok.

Thanks

LastWord: You can look with plugin Query Monitor (remove acf-image-aspect-ratio-crop-settings option from your DB)

Crop buttons not displaying

I installed the plugin on my dev site and it worked perfectly. Now I've uploaded the files to live I've got the problem that the crop buttons aren't showing. Inspecting suggests that they're below the bottom of the screen, but I can't see how to access them
image

"original_image" is blank if crop is same as original image

Not sure if this is an issue, but just making a note here if it's not expected behavior.

BTW to start, this is a great plugin! It's super-useful to have crops tied to an image. I worked with another CMS (Blox) and that was very useful.

I am using this for a set of thumbnail images (which use the cropped version) that, when clicked, show a larger image (the original version) in a lightbox.

I currently access the thumbnail by (variable name replaced for simplicity):
$work_example['image']['sizes']['medium']

And the original / larger version of the image by:
$image_aspect_ratio_field['original_image']['url']

There was one case where an thumbnail image did not need to be cropped from the original / larger image. In that case, 'original_image' was null, and the lightbox didn't work.

Cropping the image just by a few pixels caused 'original_image' to not be null, so I'm assuming it's only populated when a crop different from the original image is made.

Allow using admin-ajax.php instead of REST API

There's at least one bug report that cropping REST API endpoint returns 403 error.

Maybe we should add an option to allow using admin-ajax.php instead of REST API for those users having issues.

re-editing crop opens modal full window height and buttons are not visible

Hi,

we updated to Version 3.3.1

when we go to re-edit the crop, the modal dialog opens up full window height and the buttons are off screen (and can't be scrolled since it's fixed)

  • crop is set 1440x500
  • the image in the cropper is 800x277.7
  • the rest is filled with a checkerboard background outside of the crop handles
  • however the modal content dimensions are now 800x969 (<div class="cropper-drag-box cropper-crop cropper-modal" data-cropper-action="crop"></div>).. whereas for new images the modal content is eg 800x533

thanks
J

PHP 8 gives an error on front-end forms

Using acf_form on the front-end, i'm getting the following error:

acf_form(array(
      'post_id' => 'user_' . get_current_user_id(),
      'field_groups' => array('group_5fcdeb724f2b2'),
      'uploader' => 'basic',
      'submit_value'	=> 'Edit'
 ));

Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in C:\Bitnami\wampstack-8.0.0-1\apache2\htdocs\plugins\acf-image-aspect-ratio-crop\fields\class-npx-acf-field-image-aspect-ratio-crop-v5.php:496

Clean Media Library

Hello, is there a way to purge the media library of unused crops. Meaning if I recrop multiple times I get all the variations linked to my post but I want only to keep the one currently linked? Is there a hook to enable this already?

Image Optimization

Are the images produced by the crop "known" to WordPress?

I am asking to see if there is any way a Plugin like ShortPixel could work for them to optimize the load and size of the images by local optimization?

Best regards

GraphQL problem

Doesn't have option for GraphQL. All other fields from ACF currently support GraphQL.

plugin stalls media library

I noticed a significant lag when trying to select an image for an acf field, this also seems to happen when viewing the media library /wp-admin/upload.php. It lags so bad that the admin becomes completely unresponsive for various seconds (20-30 seconds). I was able to track it down to this plugin, after deactivating it, media library loads fine and is immediately responsive. Do you know what could be causing this?

Fail to crop

Hello,

I have an issue with the last version of the plugin 5.0.5 - I'm always getting an error "fail to crop" when I'm trying to import an image through the wordpress back-end. I'm using the last version of local by flywheel on mac OS Big sur.

Checking the JS console gave me this. "https://eau-de-lavey.local/wp-json/aiarc/v1/crop 40"
Capture d’écran 2021-01-21 à 17 16 32

I found a related topic here : https://wordpress.org/support/topic/failed-to-crop/ but couldn't solve it.

Downgraded to 4.1.4 and everything's fine now !

Tks

Required check is ignored

Since the update to Version 4.1.0 the "Required?" option seems to be ignored.
It is possible to update a page without adding an image to the required field.

Min. width and height disregarded when pixel size chosen as crop type

I've created a field with crop type "Pixel size" and a width and height of 800x600 pixels. Your plugin automatically fills out the minimum required size to match the entered width and height.

The problem is, that even though the minimum requirements are set, I can still choose a smaller image, which I'm not supposed to. I tested using an image with the dimensions 700x671 pixels . Apparently the minimum requirements are disregarded.

If I set minimum size requirements for the crop type "Aspect ratio", it's working as intended and I'm not allowed to choose a smaller image than what's defined.

Active plugins:

  • ACF Pro 5.8.9
  • Advanced Custom Fields: Image Aspect Ratio Crop 3.2.0
  • WooCommerce 4.0.1
  • Yoast SEO 13.4.1

Other details

  • Wordpress 5.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.