public static function get_image_params( $timber_image, $img_size ) {
		list(
			$file_src,
			$max_width,
			$max_height
		) = wp_get_attachment_image_src( $timber_image->ID, 'full' );

		$oversize_defaults = array(
			'allow'      => false,
			'style_attr' => true,
		);

		/**
		 * Filters the default oversize parameters used for an image.
		 *
		 * An oversize parameter set for an individual image size will always overwrite values set through this filter.
		 *
		 * @since 0.13.1
		 *
		 * @param array|bool $oversize_defaults Default oversize parameters. Can be a boolean to set all values in the
		 *                                      array or an array with keys `allow` and `style_attr`.
		 *                                      Default `array( 'allow' => false, 'style_attr' => true )`.
		 */
		$oversize = apply_filters( 'timmy/oversize', $oversize_defaults );

		// Overwrite default value with oversize value
		$oversize = isset( $img_size['oversize'] ) ? $img_size['oversize'] : $oversize;

		// Turn shortcut boolean value for oversize into array
		if ( is_bool( $oversize ) ) {
			$oversize = array(
				'allow'      => $oversize,
				'style_attr' => $oversize,
			);
		}

		// Make sure all required values are set.
		$oversize = wp_parse_args( $oversize, $oversize_defaults );

		$resize = $img_size['resize'];

		// Get values for the default image size
		list( $width, $height ) = Helper::get_dimensions_for_size( $img_size );

		/**
		 * Check oversize.
		 *
		 * If oversize is not allowed, then the image will not grow over its original size.
		 *
		 * Check whether the image source width is smaller than the desired width
		 * or the image source height is smaller than the desired height.
		 *
		 * Inline styles will only be applied if $oversize['allow'] is false. It doesn’t make
		 * sense to include bigger, low-quality sizes and still constrain an image’s dimensions.
		 */
		if ( ! $oversize['allow'] ) {
			if ( $width > $max_width ) {
				// Overwrite $width to use a max width
				$width = $max_width;

				// Calculate new height based on new width
				if ( isset( $resize[1] ) ) {
					$height = (int) round( $width * ( $resize[1] / $resize[0] ) );
				}

				if ( $oversize['style_attr'] ) {
					// Restrict to width
					$oversize['style_attr'] = 'width';
				}
			} elseif ( $height > 0 && $height > $max_height ) {
				$height = $max_height;
				$width  = (int) round( $max_width / $max_height * $height );

				if ( $oversize['style_attr'] ) {
					// Restrict to height
					$oversize['style_attr'] = 'height';
				}
			}
		}

		$crop  = Helper::get_crop_for_size( $img_size );
		$force = Helper::get_force_for_size( $img_size );

		return array(
			$file_src,
			$width,
			$height,
			$crop,
			$force,
			$max_width,
			$max_height,
			$oversize,
		);
	}
public static function get_image_params( $timber_image, $img_size ) {
		list(
			$file_src,
			$max_width,
			$max_height
		) = wp_get_attachment_image_src( $timber_image->ID, 'full' );

		$oversize_defaults = array(
			'allow'      => false,
			'style_attr' => true,
		);

		/**
		 * Filters the default oversize parameters used for an image.
		 *
		 * An oversize parameter set for an individual image size will always overwrite values set through this filter.
		 *
		 * @since 0.13.1
		 *
		 * @param array|bool $oversize_defaults Default oversize parameters. Can be a boolean to set all values in the
		 *                                      array or an array with keys `allow` and `style_attr`.
		 *                                      Default `array( 'allow' => false, 'style_attr' => true )`.
		 */
		$oversize = apply_filters( 'timmy/oversize', $oversize_defaults );

		// Overwrite default value with oversize value
		$oversize = isset( $img_size['oversize'] ) ? $img_size['oversize'] : $oversize;

		// Turn shortcut boolean value for oversize into array
		if ( is_bool( $oversize ) ) {
			$oversize = array(
				'allow'      => $oversize,
				'style_attr' => $oversize,
			);
		}

		// Make sure all required values are set.
		$oversize = wp_parse_args( $oversize, $oversize_defaults );

		$resize = $img_size['resize'];

		// Get values for the default image size
		list( $width, $height ) = Helper::get_dimensions_for_size( $img_size );

		/**
		 * Check oversize.
		 *
		 * If oversize is not allowed, then the image will not grow over its original size.
		 *
		 * Check whether the image source width is smaller than the desired width
		 * or the image source height is smaller than the desired height.
		 *
		 * Inline styles will only be applied if $oversize['allow'] is false. It doesn’t make
		 * sense to include bigger, low-quality sizes and still constrain an image’s dimensions.
		 */
		if ( ! $oversize['allow'] ) {
			if ( $width > $max_width ) {
				// Overwrite $width to use a max width
				$width = $max_width;

				// Calculate new height based on new width
				if ( isset( $resize[1] ) ) {
					$height = (int) round( $width * ( $resize[1] / $resize[0] ) );
				}

				if ( $oversize['style_attr'] ) {
					// Restrict to width
					$oversize['style_attr'] = 'width';
				}
			} elseif ( $height > 0 && $height > $max_height ) {
				$height = $max_height;
				$width  = (int) round( $max_width / $max_height * $height );

				if ( $oversize['style_attr'] ) {
					// Restrict to height
					$oversize['style_attr'] = 'height';
				}
			}
		}

		$crop  = Helper::get_crop_for_size( $img_size );
		$force = Helper::get_force_for_size( $img_size );

		return array(
			$file_src,
			$width,
			$height,
			$crop,
			$force,
			$max_width,
			$max_height,
			$oversize,
		);
	}
public static function get_image_params ( $ timber_image , $ img_size ) { list ( $ file_src , $ max_width , $ max_height ) = wp_get_attachment_image_src ( $ timber_image -> ID , 'full' ) ; $ oversize_defaults = array ( 'allow' => false , 'style_attr' => true , ) ; /**
		 * Filters the default oversize parameters used for an image.
		 *
		 * An oversize parameter set for an individual image size will always overwrite values set through this filter.
		 *
		 * @since 0.13.1
		 *
		 * @param array|bool $oversize_defaults Default oversize parameters. Can be a boolean to set all values in the
		 *                                      array or an array with keys `allow` and `style_attr`.
		 *                                      Default `array( 'allow' => false, 'style_attr' => true )`.
		 */ $ oversize = apply_filters ( 'timmy/oversize' , $ oversize_defaults ) ; // Overwrite default value with oversize value $ oversize = isset ( $ img_size [ 'oversize' ] ) ? $ img_size [ 'oversize' ] : $ oversize ; // Turn shortcut boolean value for oversize into array if ( is_bool ( $ oversize ) ) { $ oversize = array ( 'allow' => $ oversize , 'style_attr' => $ oversize , ) ; } // Make sure all required values are set. $ oversize = wp_parse_args ( $ oversize , $ oversize_defaults ) ; $ resize = $ img_size [ 'resize' ] ; // Get values for the default image size list ( $ width , $ height ) = Helper :: get_dimensions_for_size ( $ img_size ) ; /**
		 * Check oversize.
		 *
		 * If oversize is not allowed, then the image will not grow over its original size.
		 *
		 * Check whether the image source width is smaller than the desired width
		 * or the image source height is smaller than the desired height.
		 *
		 * Inline styles will only be applied if $oversize['allow'] is false. It doesn’t make
		 * sense to include bigger, low-quality sizes and still constrain an image’s dimensions.
		 */ if ( ! $ oversize [ 'allow' ] ) { if ( $ width > $ max_width ) { // Overwrite $width to use a max width $ width = $ max_width ; // Calculate new height based on new width if ( isset ( $ resize [ 1 ] ) ) { $ height = ( int ) round ( $ width * ( $ resize [ 1 ] / $ resize [ 0 ] ) ) ; } if ( $ oversize [ 'style_attr' ] ) { // Restrict to width $ oversize [ 'style_attr' ] = 'width' ; } } elseif ( $ height > 0 && $ height > $ max_height ) { $ height = $ max_height ; $ width = ( int ) round ( $ max_width / $ max_height * $ height ) ; if ( $ oversize [ 'style_attr' ] ) { // Restrict to height $ oversize [ 'style_attr' ] = 'height' ; } } } $ crop = Helper :: get_crop_for_size ( $ img_size ) ; $ force = Helper :: get_force_for_size ( $ img_size ) ; return array ( $ file_src , $ width , $ height , $ crop , $ force , $ max_width , $ max_height , $ oversize , ) ; }
Get an array with image parameters required for generating a new size.

@since 0.10.0

@param Timber\Image|int $timber_image Instance of TimberImage.
@param array            $img_size     Image configuration array for image size to be used.

@return array An non-associative array with $file_src, $width, $height, $crop, $force,
$max_width, $undersized (in that order). Thought to be used with list().
Get an array with image parameters required for generating a new size .