RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.38% (6.14%*) • Home Loan Fixed: 5.44% (6.26%*) • Fixed: 5.44% (6.26%*) • Variable: 5.38% (6.14%*) • Investment IO: 5.69% (6.52%*) • Investment PI: 5.49% (5.98%*)

WordPress ‘get intermediate image sizes’ Functions

WordPress' get intermediate image sizes() function is used to "get the available image sizes". The functions below, from the WP Codex , are a handy reference for dealing with available sizes. the following function will list available image sizes with width and height following.

The snippets are included to support the article "Import Remote Images into WordPress and Return Image URL, Image ID, and Image Dimensions" on this page.

1
<?php 
2
/*
3
 Get size information for all currently-registered image sizes.
4
 @global $_wp_additional_image_sizes
5
 @uses   get_intermediate_image_sizes()
6
 @return array $sizes Data for all currently-registered image sizes.
7
*/
8
 
9
function get_image_sizes() {
10
 
11
 global $_wp_additional_image_sizes;
12
 $sizes = array();
13
 
14
 foreach ( get_intermediate_image_sizes() as $_size ) {
15
  if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) {
16
   $sizes[ $_size ]['width']  = get_option( "{$_size}_size_w" );
17
   $sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" );
18
   $sizes[ $_size ]['crop']   = (bool) get_option( "{$_size}_crop" );
19
  } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
20
   $sizes[ $_size ] = array(
21
    'width'  => $_wp_additional_image_sizes[ $_size ]['width'],
22
    'height' => $_wp_additional_image_sizes[ $_size ]['height'],
23
    'crop'   => $_wp_additional_image_sizes[ $_size ]['crop'],
24
   );
25
  }
26
 }
27
 
28
 return $sizes;
29
}
30
 
31
/*
32
 Get size information for a specific image size.
33
 @uses   get_image_sizes()
34
 @param  string $size The image size for which to retrieve data.
35
 @return bool|array $size Size data about an image size or false if the size doesn't exist.
36
*/
37
 
38
function get_image_size( $size ) {
39
  $sizes = get_image_sizes();
40
  if ( isset( $sizes[ $size ] ) ) return $sizes[ $size ];
41
  else return false;
42
}
43
 
44
/*
45
 Get the width of a specific image size.
46
 @uses   get_image_size()
47
 @param  string $size The image size for which to retrieve data.
48
 @return bool|string $size Width of an image size or false if the size doesn't exist.
49
*/
50
 
51
function get_image_width( $size ) {
52
  if ( ! $size = get_image_size( $size ) ) return false;
53
  if ( isset( $size['width'] ) ) return $size['width'];
54
 
55
 return false;
56
}
57
 
58
/*
59
 Get the height of a specific image size.
60
 @uses   get_image_size()
61
 @param  string $size The image size for which to retrieve data.
62
 @return bool|string $size Height of an image size or false if the size doesn't exist.
63
*/
64
 
65
function get_image_height( $size ) {
66
  if ( ! $size = get_image_size( $size ) ) return false;
67
  if ( isset( $size['height'] ) ) return $size['height'];
68
 
69
 return false;
70
}

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment