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/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -643,6 +643,29 @@ function get_intermediate_image_sizes() {
 }
 
 /**
+ * Get an array of image size names with their width, height and crop value.
+ * @uses get_intermediate_image_sizes()
+ * @since 4.0.0
+ * @return array
+ */
+function get_image_sizes_data() {
+	$image_sizes = get_intermediate_image_sizes();
+
+	$result = array();
+	foreach ( $image_sizes as $size ) {
+		$result[ $size ]['width']  = absint( get_option( "{$size}_size_w" ) );
+		$result[ $size ]['height'] = absint( get_option( "{$size}_size_h" ) );
+		// If not set: crop false per default.
+		$result[ $size ]['crop']   = false;
+		if ( get_option( "{$size}_crop" ) ) {
+			$result[ $size ]['crop'] = get_option( "{$size}_crop" );
+		}
+	}
+
+	return $result;
+}
+
+/**
  * Retrieve an image to represent an attachment.
  *
  * A mime icon for files, thumbnail or intermediate size for images.
-- 
1.8.5.2.msysgit.0

