FEATURE REQUEST: Make checkboxes to indicate image-sizes to be cropped
-
Hello Anders,
Thank you very much for this great plugin!
Although I think just like me, more people are dealing with the same problem: They want to have the possibility to crop only certain sizes and they want to keep some image sizes the original aspect-ratio.
(Highly Recommended) Feature request:
Make checkboxes to indicate which image-sizes needs to be cropped.So for example I select only ‘thumb-small’, ‘thumb-medium’, ‘thumb-large’ to be cropped, all other images sizes I don’t select.
This will result in:
<?php $imageArray = get_field('acf_image'); var_dump($imageArray); // Show what we have ?>
array (size=10) 'id' => int 342 'alt' => string '' (length=0) 'title' => string '20141011-160906-IMG_1168-test9_3168x4475_acf_cropped' (length=52) 'caption' => string '' (length=0) 'description' => string '' (length=0) 'mime_type' => string 'image/jpeg' (length=10) 'url' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_cropped.jpg' (length=117) 'width' => int 3168 'height' => int 4475 'sizes' => array (size=24) 'thumbnail' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_150x150.jpg' (length=125) 'thumbnail-width' => int 150 'thumbnail-height' => int 150 'medium' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_300x300.jpg' (length=125) 'medium-width' => int 300 'medium-height' => int 300 'large' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_1024x1024.jpg' (length=125) 'large-width' => int 1024 'large-height' => int 1024 'wysija-newsletters-max' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_600x848.jpg' (length=125) 'wysija-newsletters-max-width' => int 600 'wysija-newsletters-max-height' => int 848 'thumb-small' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_cropped-160x160.jpg' (length=125) 'thumb-small-width' => int 160 'thumb-small-height' => int 160 'thumb-medium' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_cropped-520x245.jpg' (length=125) 'thumb-medium-width' => int 520 'thumb-medium-height' => int 245 'thumb-large' => string 'https://project-04.website.nl:8080/wp-content/uploads/2014/12/20141011-160906-IMG_1168-test9_3168x4475_acf_cropped-720x340.jpg' (length=125) 'thumb-large-width' => int 720 'thumb-large-height' => int 340
So in my case I have checked only ‘thumb-small’, ‘thumb-medium’, ‘thumb-large’, to be cropped. But the default wordpress ‘thumbnail’, ‘medium’, ‘large’ and ‘wysija-newsletters’ are NOT cropped, but they are still part of the array.
This approach has some advantages:
#1. Easily possible to select and display the wanted image.
By using code below I can choose the default ‘large’ image size.<?php $imageArray = get_field('acf_image'); // Array returned by Advanced Custom Fields $imageAlt = $imageArray['alt']; // Grab, from the array, the 'alt' $imageURL = $imageArray['url']; // Grab the full size version for lightbox $imageThumbURL = $imageArray['sizes']['large']; //grab from the array, the 'sizes', and from it, the 'large' ?> <a href="<?php echo $imageURL; ?>"> <img src="<?php echo $imageThumbURL;?>" alt="<?php echo $imageAlt; ?>"> </a>
By using code below I can choose the cropped version called ‘thumb-large’ image size.
<?php $imageArray = get_field('acf_image'); // Array returned by Advanced Custom Fields $imageAlt = $imageArray['alt']; // Grab, from the array, the 'alt' $imageURL = $imageArray['url']; // Grab the full size version for lightbox $imageThumbURL = $imageArray['sizes']['thumb-large']; //grab from the array, the 'sizes', and from it, the 'thumb-large' ?> <a href="<?php echo $imageURL; ?>"> <img src="<?php echo $imageThumbURL;?>" alt="<?php echo $imageAlt; ?>"> </a>
#2.When uploading image into a post, there is only one image upload needed. Because the same uploaded image (e.g. image ‘large’) can be used in ‘the_content’ itself and also as featured_image (e.g. image ‘thumb-large’). I can even use the original thumbnail as well.
#3.End-user only needs to upload image once, but we can use it in three different situations. This mean less cluthering of the media library.
What do you think?
- The topic ‘FEATURE REQUEST: Make checkboxes to indicate image-sizes to be cropped’ is closed to new replies.