From 63a92698d05d6f13920d72ebaeeb831475466805 Mon Sep 17 00:00:00 2001
From: Kaiser Franz Josef <wecodemore@gmail.com>
Date: Sun, 25 May 2014 14:36:19 +0200
Subject: [PATCH] Added new function get_images_sizes_data() that returns an
array of registered image sizes alongside their width, height and crop value
---
wp-includes/media.php | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/wp-includes/media.php b/wp-includes/media.php
index f9b47e4..b695527 100644
|
a
|
b
|
function get_intermediate_image_sizes() { |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
| | 646 | * Get an array of image size names with their width, height and crop value. |
| | 647 | * @uses get_intermediate_image_sizes() |
| | 648 | * @since 4.0.0 |
| | 649 | * @return array |
| | 650 | */ |
| | 651 | function get_image_sizes_data() { |
| | 652 | $image_sizes = get_intermediate_image_sizes(); |
| | 653 | |
| | 654 | $result = array(); |
| | 655 | foreach ( $image_sizes as $size ) { |
| | 656 | $result[ $size ]['width'] = absint( get_option( "{$size}_size_w" ) ); |
| | 657 | $result[ $size ]['height'] = absint( get_option( "{$size}_size_h" ) ); |
| | 658 | // If not set: crop false per default. |
| | 659 | $result[ $size ]['crop'] = false; |
| | 660 | if ( get_option( "{$size}_crop" ) ) { |
| | 661 | $result[ $size ]['crop'] = get_option( "{$size}_crop" ); |
| | 662 | } |
| | 663 | } |
| | 664 | |
| | 665 | return $result; |
| | 666 | } |
| | 667 | |
| | 668 | /** |
| 646 | 669 | * Retrieve an image to represent an attachment. |
| 647 | 670 | * |
| 648 | 671 | * A mime icon for files, thumbnail or intermediate size for images. |