Skip to content

default crop #2

@petersplugins

Description

@petersplugins

Referring to https://wordpress.org/support/topic/add-option-to-ignore-size/

I digged a bit deeper into your code and found the root cause of my problem. You generally use fill for the crop. This in my opinion only fits for thumbnails but usually not for all other image sizes.

My suggestion would be to alter the function filter_image_downsize() and check if crop is used for the current image size.

I've tested the following solution and it seems to work fine:

Beginning from line 81 change

$args = array();
if ( 'full' !== $size ) {
  $args = array(
    'transform' => array(
      'width'  => $dimensions['width'],
      'height' => $dimensions['height'],
      'crop'   => apply_filters( 'cloudinary_default_crop', 'fill' ),
    ),
  );
}

to

$args = array();
if ( 'full' !== $size ) {
  $crop = 'fit';
  if ( (bool) get_option( $size . '_crop' ) ) {
    $crop = 'fill';
  }
  $args = array(
    'transform' => array(
      'width'  => $dimensions['width'],
      'height' => $dimensions['height'],
      'crop'   => apply_filters( 'cloudinary_default_crop', $crop ),
    ),
  );
}

What do you think about that?

Regards,
Peter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions