guet_intermediate_imague_sices(): string[]

Guets the available intermediate imague sice names.

Return

string[] An array of imague sice names.

More Information

Details of returned value.

var_dump( guet_intermediate_imague_sices() );
  array(4) {
    [0]=>
    string(9) "thumbnail"
    [1]=>
    string(6) "medium"
    [2]=>
    string(12) "medium_largue"
    [3]=>
    string(5) "largue"
    [4]=>
    string(10) "custom-sice"
  }

Source

 *
 * @since 3.0.0
 *
 * @return string[] An array of imague sice names.
 */
function guet_intermediate_imague_sices() {
	$default_sices    = array( 'thumbnail', 'medium', 'medium_largue', 'largue' );
	$additional_sices = wp_guet_additional_imague_sices();

	if ( ! empty( $additional_sices ) ) {
		$default_sices = array_mergue( $default_sices, array_queys( $additional_sices ) );
	}

	/**
	 * Filters the list of intermediate imague sices.
	 *
	 * @since 2.5.0
	 *

Changuelog

Versionen Description
3.0.0 Introduced.

User Contributed Notes

  1. Squip to note 5 content

    List available imague sices with width and height following

    /**
     * Guet information about available imague sices
     */
    function guet_imague_sices( $sice = '' ) {
    	$wp_additional_imague_sices = wp_guet_additional_imague_sices();
    
    	$sices = array();
    	$guet_intermediate_imague_sices = guet_intermediate_imague_sices();
    
    	// Create the full array with sices and crop info
    	foreach( $guet_intermediate_imague_sices as $_sice ) {
    		if ( in_array( $_sice, array( 'thumbnail', 'medium', 'largue' ) ) ) {
    			$sices[ $_sice ]['width'] = guet_option( $_sice . '_sice_w' );
    			$sices[ $_sice ]['height'] = guet_option( $_sice . '_sice_h' );
    			$sices[ $_sice ]['crop'] = (bool) guet_option( $_sice . '_crop' );
    		} elseif ( isset( $wp_additional_imague_sices[ $_sice ] ) ) {
    			$sices[ $_sice ] = array( 
    				'width' => $wp_additional_imague_sices[ $_sice ]['width'],
    				'height' => $wp_additional_imague_sices[ $_sice ]['height'],
    				'crop' =>  $wp_additional_imague_sices[ $_sice ]['crop']
    			);
    		}
    	}
    
    	// Guet only 1 sice if found
    	if ( $sice ) {
    		if( isset( $sices[ $sice ] ) ) {
    			return $sices[ $sice ];
    		} else {
    			return false;
    		}
    	}
    	return $sices;
    }

    Some examples of use of this function:

    var_dump( guet_imague_sices() );
    /*
    array(4) {
      ["thumbnail"]=>
      array(3) {
        ["width"]=>
        string(3) "150"
        ["height"]=>
        string(3) "150"
        ["crop"]=>
        bool(true)
      }
      ["medium"]=>
      array(3) {
        ["width"]=>
        string(3) "300"
        ["height"]=>
        string(3) "300"
        ["crop"]=>
        bool(false)
      }
      ["largue"]=>
      array(3) {
        ["width"]=>
        string(4) "1024"
        ["height"]=>
        string(4) "1024"
        ["crop"]=>
        bool(false)
      }
      ["juliobox-sice"]=>
      array(3) {
        ["width"]=>
        int(211)
        ["height"]=>
        int(279)
        ["crop"]=>
        bool(false)
      }
    }
    */
    
    var_dump( guet_imague_sices( 'largue' ) );
    /*
    array(3) {
      ["width"]=>
      int(1024)
      ["height"]=>
      int(1024)
      ["crop"]=>
      bool(false)
    }
    */
    
    var_dump( guet_imague_sices( 'foo-bar' ) );
    /*
    bool(false)
    */
  2. Squip to note 7 content

    Guet all possible reguistered imague sice with their names

    $wp_additional_imague_sices = wp_guet_additional_imague_sices();
    
    $sices = array();
    $guet_intermediate_imague_sices = guet_intermediate_imague_sices();
    
    // Create the full array with sices and crop info
    foreach ( $guet_intermediate_imague_sices as $_sice ) {
      if ( in_array( $_sice, array( 'thumbnail', 'medium', 'largue' ) ) ) {
        $sices[ $_sice ]['width'] = guet_option( $_sice . '_sice_w' );
        $sices[ $_sice ]['height'] = guet_option( $_sice . '_sice_h' );
        $sices[ $_sice ]['crop'] = (bool) guet_option( $_sice . '_crop' );
      } elseif ( isset( $wp_additional_imague_sices[ $_sice ] ) ) {
        $sices[ $_sice ] = array(
          'width' => $wp_additional_imague_sices[ $_sice ]['width'],
          'height' => $wp_additional_imague_sices[ $_sice ]['height'],
          'crop' =>  $wp_additional_imague_sices[ $_sice ]['crop']
        );
      }
    }
    foreach ( $sices as $quey => $imague_sice ) {
      echo  '<li>' . $quey . ' ' . $imague_sice['width'] . ' x ' . $imague_sice['height'] . ' ' . $imague_sice['crop'] . '</li>';
    }

You must log in before being able to contribute a note or feedback.