Support » Plugin: Media Library Assistant » Interferes with ACF: Image Aspect Ratio Crop Field functionality

  • kisabelle

    (@kisabelle)


    I’m having an issue where this plugin is interfering with Advanced Custom Fields: Image Aspect Ratio Crop Field plugin’s functionality in a couple of ways.

    Link to plugin: https://wordpress.org/plugins/acf-image-aspect-ratio-crop/

    1. Media Library Assistant causes WordPress to ignore any ajax_query_attachments_args filters set by the theme or other plugins (add_filter('ajax_query_attachments_args' ...)).

    2. Media Library Assistant interferes with size limits set on the ACF: Image Aspect Ratio Crop field. For example when setting the minimum width to 1000px some images smaller than 1000px are still available to select. Disabling Media Library Assistant resolves the issue.

    Is there a way to adjust the plugin’s code or settings to enable the use of the ajax_query_attachments_args ? As this is causing me a lot of trouble.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter kisabelle

    (@kisabelle)

    Update: I was able to resolve this by disabling the following setting:

    Enable Media Manager Enhancements
    Check/uncheck this option to enable/disable Media Manager Modal Window Enhancements.

    Plugin Author David Lingren

    (@dglingren)

    Thank you for your report and for the link to “Advanced Custom Fields: Image Aspect Ratio Crop Field”. Thanks as well for finding a work around and posting an update.

    I will have a look at supporting the filter you identified. Can you give an example of an ignored “filter set by the theme or other plugins” that I could use to test this issue?

    You wrote “For example when setting the minimum width to 1000px some images smaller than 1000px are still available to select.

    I installed the plugin (Version 5.1.2) and tested it with the ACF free version (Version 5.9.5). I created a Crop field with a minimum pixel restriction of 768×768. When I activate the “Select Image” popup window and try to select a smaller image I get “Restricted … Image height must be at least 768px.” in the upper-right corner of the window. I cannot select the image. Is this different from your results? On your site are the smaller images suppressed from the thumbnail display grid in the popup window?

    Thanks for any additional information you can provide, and for your interest in MLA.

    Thread Starter kisabelle

    (@kisabelle)

    Regarding the image size restrictions, I was seeing that out of the initial images that were loaded the restriction was in effect but scrolling down further in the Media Library modal window the images further down were not restricted by the minimum sizes anymore. Maybe it’s only when further images are loaded via AJAX as you scroll down that the issue occurs?

    Regarding the filter, below is an example of how to use it. This is actually copied out of the Advanced Custom Fields: Image Aspect Ratio Crop Field, it’s designed to prevent the cropped images from appearing in the Media Library.

    add_filter('ajax_query_attachments_args', 'myFilterAjaxQueryAttachmentArgs');
    
    function myFilterAjaxQueryAttachmentArgs($args) {
      write_log('filter ajax query attachment args');
    
      if (empty($args['post__in'])) {
        $args['meta_query'] = [
          [
            'key' => 'acf_image_aspect_ratio_crop',
            'compare' => 'NOT EXISTS',
          ],
        ];
      }
    
      return $args;
    }

    Note that I am calling a custom function, write_log() which writes to the debug log, this is how I was able to tell that the filter was being bypassed.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the details about the filter use.

    I have uploaded a new MLA Development Version dated 2021025 that adds support for the ajax_query_attachments_args filter. You can find step-by-step instructions for using the Development Version in this support topic:

    PHP Warning on media upload with Polylang

    It would be great if you could install the Development Version and let me know if it works for you. Thanks again for alerting me to this MLA defect.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.