Generate image sizes defined for Timmy with Timber\ImageHelper.

@param int $attachment_id The attachment ID for which all images should be resized.

@return array An array of generated image sizes that will be saved in attachment metdata.
489996
private function timber_generate_sizes( $attachment_id ) {
		$sizes      = [];
		$img_sizes  = Helper::get_image_sizes();
		$attachment = get_post( $attachment_id );

		/**
		 * Never automatically generate image sizes on upload for SVG and GIF images.
		 * SVG and GIF images will still be resized when requested on the fly.
		 */
		if ( in_array( $attachment->post_mime_type, array(
			'image/svg+xml',
			'image/gif',
		), true ) ) {
			return $sizes;
		}

		// Timber needs the file src as an URL
		$file_src  = wp_get_attachment_url( $attachment_id );
		$meta_data = wp_get_attachment_metadata( $attachment_id );

		/**
		 * Delete all existing image sizes for that file.
		 *
		 * This way, when Regenerate Thumbnails will be used, all non-registered image sizes will be
		 * deleted as well. Because Timber creates image sizes when they’re needed, we can safely do
		 * this.
		 */
		Timber\ImageHelper::delete_generated_files( $file_src );

		foreach ( $img_sizes as $key => $img_size ) {
			if ( ! $this->timber_should_resize( $attachment->post_parent, $img_size ) ) {
				continue;
			}

			// Create downsized version of the image
			$downsized = image_downsize( $attachment_id, $key );

			// Bail out if there was an error while downsizing the image.
			if ( ! is_array( $downsized ) ) {
				continue;
			}

			list( $file_src, $file_width, $file_height ) = $downsized;

			/**
			 * Create an image definition array that will be used for attachment metadata.
			 *
			 * WordPress saves an array with the file src, the width, the height and the mime type
			 * of an attachment in the postmeta database table. By generating this array and saving
			 * it in the database, we can improve the compatibility with the core image
			 * functionality.
			 *
			 * Correct width and height values of '0' by calculating them from the original image
			 * ratio, if meta data is available.
			 */
			if ( ! empty( $meta_data['height'] ) && ! empty( $meta_data['width'] ) ) {
				if ( 0 === (int) $file_width && ! empty( $meta_data['height'] ) ) {
					$file_width = round( $file_height / $meta_data['height'] * $meta_data['width'] );
				} elseif ( 0 === (int) $file_height ) {
					$file_height = round( $file_width / $meta_data['width'] * $meta_data['height'] );
				}
			}

			if ( is_numeric( $file_width ) && is_numeric( $file_height ) ) {
				$sizes[ $key ] = [
					'file'      => wp_basename( $file_src ),
					'width'     => $file_width,
					'height'    => $file_height,
					'mime-type' => wp_check_filetype( $file_src )['type'],
				];
			}

			/**
			 * Filters whether srcset sizes should be generated when an image is uploaded.
			 *
			 * @since 0.13.0
			 *
			 * @param bool     $generate_srcset_sizes Whether to generate srcset sizes. Passing false will prevent
			 *                                        srcset sizes to generated when an image is uploaded. Default false.
			 * @param string   $key                   The image size key.
			 * @param array    $img_size              The image size configuration array.
			 * @param \WP_Post $attachment            The attachment post.
			 */
			$generate_srcset_sizes = apply_filters( 'timmy/generate_srcset_sizes', false, $key, $img_size, $attachment );

			// Get setting from image configuration.
			$generate_srcset_sizes = isset( $img_size['generate_srcset_sizes'] )
				? $img_size['generate_srcset_sizes']
				: $generate_srcset_sizes;

			if ( false === $generate_srcset_sizes ) {
				continue;
			}

			// Get values for the default image
			$crop  = Helper::get_crop_for_size( $img_size );
			$force = Helper::get_force_for_size( $img_size );

			// Generate additional image sizes used for srcset
			if ( isset( $img_size['srcset'] ) ) {
				foreach ( $img_size['srcset'] as $srcset_size ) {
					list( $width, $height ) = Helper::get_dimensions_for_srcset_size( $img_size['resize'], $srcset_size );

					// For the new source, we use the same $crop and $force values as the default image
					self::resize( $img_size, $file_src, $width, $height, $crop, $force );
				}
			}
		}

		return $sizes;
	}
889164
public function getAttachedFile($file, $attachment_id) {
	    $shouldOverride = apply_filters('ilab_should_override_attached_file', true, $attachment_id);

		if(!file_exists($file) && $shouldOverride) {
			$meta = wp_get_attachment_metadata($attachment_id);

			$new_url = null;
			if($meta) {
				$new_url = $this->getAttachmentURLFromMeta($meta);
			}

			if(!$new_url) {
				$meta = get_post_meta($attachment_id, 'ilab_s3_info', true);
				if($meta) {
					$new_url = $this->getAttachmentURLFromMeta($meta);
				} else if(!$meta && StorageSettings::docCdn()) {
					$post = \WP_Post::get_instance($attachment_id);
					if($post && (strpos($post->guid, StorageSettings::docCdn()) === 0)) {
						$new_url = $post->guid;
					}
				}
			}

			if($new_url) {
				return $new_url;
			}
		}

		return $file;
	}
599719
public function getPostAttachment($size = 'full', $property = null)
    {
        $post_id = $this->get('ID');
        if (!has_post_thumbnail($post_id)) {
            return false;
        }
        
        $attachment_id = get_post_thumbnail_id($post_id);
        $image_properties = array(
            'url',
            'width',
            'height',
            'is_resized'
        );
        $image_array = array_combine(
            $image_properties,
            array_values(wp_get_attachment_image_src($attachment_id, $size))
        );
        if (in_array($property, $image_properties)) {
            return $image_array[$property];
        }
        return $image_array;
    }
160196
private function buildImgixImage($id, $size, $params = null, $skipParams = false, $mergeParams = null, $newSize = null, $newMeta=null) {
		if(is_array($size)) {
			return $this->buildSizedImgixImage($id, $size);
		}

		$mimetype = get_post_mime_type($id);

        if (!$this->renderPDF && ($mimetype == 'application/pdf')) {
            return false;
        }

		$meta = wp_get_attachment_metadata($id);
		if(!$meta || empty($meta)) {
			if(($this->renderPDF && ($mimetype == 'application/pdf')) || ($this->enabledAlternativeFormats && ($mimetype == 'application/vnd.adobe.illustrator'))) {
				$meta = get_post_meta($id, 'ilab_s3_info', true);
			}

			if(!$meta || empty($meta)) {
			    if (!empty($newMeta)) {
			        $meta = $newMeta;
                } else {
				    return false;
                }
			}
		}

		if(!isset($meta['s3'])) {
			if(($this->renderPDF && ($mimetype == 'application/pdf')) || ($this->enabledAlternativeFormats && ($mimetype == 'application/vnd.adobe.illustrator'))) {
				$meta = get_post_meta($id, 'ilab_s3_info', true);
			} else {
				return false;
			}
		}

		$imgix = new UrlBuilder($this->imgixDomains, $this->useHTTPS);

		if($this->signingKey) {
			$imgix->setSignKey($this->signingKey);
		}

		if($size == 'full' && !$newSize) {
			if(!isset($meta['width']) || !isset($meta['height'])) {
				return false;
			}

			if(!$params) {
				if(isset($meta['imgix-params'])) {
					$params = $meta['imgix-params'];
				} else {
					$params = [];
				}
			}

			$params = $this->buildImgixParams($params, $mimetype);
			$params = apply_filters('ilab-imgix-filter-parameters', $params, $size, $id, $meta);

			if(!isset($meta['file'])) {
				return null;
			}

			$imageFile = (isset($meta['s3'])) ? $meta['s3']['key'] : $meta['file'];

			$result = [
				$imgix->createURL(str_replace('%2F', '/', urlencode($imageFile)), ($skipParams) ? [] : $params),
				$meta['width'],
				$meta['height'],
				false
			];

			return $result;
		}

		if($newSize) {
			$sizeInfo = $newSize;
		} else {
			$sizeInfo = ilab_get_image_sizes($size);
		}

		if(!$sizeInfo) {
			return false;
		}

		$metaSize = null;
		if(isset($meta['sizes'][$size])) {
			$metaSize = $meta['sizes'][$size];
		}

		$doCrop = !empty($sizeInfo['crop']);

		if(!$params) {
		    $sizeParams = (!empty($sizeInfo['imgix']) && is_array($sizeInfo['imgix'])) ? $sizeInfo['imgix'] : [];
		    $sizeCropParams = (isset($sizeParams['crop'])) ? $sizeParams['crop'] : [];
		    if (!empty($sizeCropParams)) {
                if (is_string($sizeCropParams)) {
                    $sizeCropParams = explode(',', $sizeCropParams);
                    unset($sizeParams['crop']);
                }

                $doCrop = true;
            }

            // get the settings for this image at this size
			if(isset($meta['imgix-size-params'][$size])) {
				$params = array_merge($sizeParams, $meta['imgix-size-params'][$size]);
			}


			if(!$params || (count($params) == 0)) // see if a preset has been globally assigned to a size and use that
			{
				$presets = get_option('ilab-imgix-presets');
				$sizePresets = get_option('ilab-imgix-size-presets');

				if($presets && $sizePresets && isset($sizePresets[$size]) && isset($presets[$sizePresets[$size]])) {
					$params = array_merge($sizeParams, $presets[$sizePresets[$size]]['settings']);
				}
			}

			// still no parameters?  use any that may have been assigned to the full size image
			if((!$params || (count($params) == 0)) && (isset($meta['imgix-params']))) {
				$params = array_merge($sizeParams, $meta['imgix-params']);
			} else if(!$params) // too bad so sad
			{
				$params = $sizeParams;
			}
		}

		if ($doCrop) {
			$params['w'] = $sizeInfo['width'] ?: $sizeInfo['height'];
			$params['h'] = $sizeInfo['height'] ?: $sizeInfo['width'];
			$params['fit'] = 'crop';

			if($metaSize) {
				$metaSize = $meta['sizes'][$size];
				if(isset($metaSize['crop'])) {
					$metaSize['crop']['x'] = round($metaSize['crop']['x']);
					$metaSize['crop']['y'] = round($metaSize['crop']['y']);
					$metaSize['crop']['w'] = round($metaSize['crop']['w']);
					$metaSize['crop']['h'] = round($metaSize['crop']['h']);
					$params['rect'] = implode(',', $metaSize['crop']);
				}
			}

			// we don't want to scale animated gifs AT ALL on the front end
			if(($mimetype == 'image/gif') && (!is_admin())) {
				$imageW = $meta['width'];
				$imageH = $meta['height'];

				$pw = $params['w'];
				$ph = $params['h'];

				if(($pw > $imageW) || ($ph > $imageH)) {
					$newSize = sizeToFitSize($pw, $ph, $imageW, $imageH);
					$params['w'] = $newSize[0];
					$params['h'] = $newSize[1];
				}
			}

			if (isset($params['focalpoint'])) {
			    unset($params['rect']);

			    if ($params['focalpoint'] == 'entropy') {
				    $params['crop'] = 'entropy';
				    unset($params['fp-x']);
				    unset($params['fp-y']);
				    unset($params['fp-z']);
                } else if ($params['focalpoint'] == 'edges') {
				    $params['crop'] = 'edges';
				    unset($params['fp-x']);
				    unset($params['fp-y']);
				    unset($params['fp-z']);
                } else {
				    $params['crop'] = 'focalpoint';
				    if ($params['focalpoint'] == 'usefaces') {
					    unset($params['fp-x']);
					    unset($params['fp-y']);

					    if (isset($meta['faces'])) {
						    $faceindex = arrayPath($params,'faceindex', 0);
						    if ((count($meta['faces'])>1) && ($faceindex == 0)) {
							    $left = 900000;
							    $top = 900000;
							    $right = 0;
							    $bottom = 0;

							    foreach($meta['faces'] as $face) {
								    $bb = $face['BoundingBox'];
								    $left = min($left, $bb['Left']);
								    $top = min($top, $bb['Top']);
								    $right = max($right, $bb['Left'] + $bb['Width']);
								    $bottom = max($bottom, $bb['Top'] + $bb['Height']);
							    }

							    $params['fp-x'] = $left + (($right - $left) / 2.0);
							    $params['fp-y'] = $top + (($bottom - $top) / 2.0);
						    } else {
							    if ($faceindex == 0) {
								    $faceindex = 1;
							    }

							    $faceindex = min(count($meta['faces'])+1, $faceindex);
							    $bb = $meta['faces'][$faceindex - 1]['BoundingBox'];

							    $params['fp-x'] = $bb['Left'] + ($bb['Width'] / 2.0);
							    $params['fp-y'] = $bb['Top'] + ($bb['Height'] / 2.0);
						    }

					    } else {
						    unset($params['crop']);
						    unset($params['fp-z']);
					    }
				    }
                }
            } else {
				unset($params['fp-x']);
				unset($params['fp-y']);
				unset($params['fp-z']);

                $cropParams = [];

                if (!empty($sizeInfo['crop']) && is_array($sizeInfo['crop'])) {
                    list($cropX, $cropY) = $sizeInfo['crop'];
                    if (!empty($cropX) && ($cropX != 'center')) {
                        $cropParams[] = $cropX;
                    }
                    if (!empty($cropY) && ($cropY != 'center')) {
                        $cropParams[] = $cropY;
                    }
                }

                if (!empty($sizeCropParams)) {
                    $cropParams = array_merge($cropParams, $sizeCropParams);
                }

                if (!empty($cropParams)) {
                    $params['crop'] = implode(",", $cropParams);
                }
            }
		} else {
			$mw = !empty($meta['width']) ? $meta['width'] : 10000;
			$mh = !empty($meta['height']) ? $meta['height'] : 10000;

			$w = !empty($sizeInfo['width']) ? $sizeInfo['width'] : 10000;
			$h = !empty($sizeInfo['height']) ? $sizeInfo['height'] : 10000;

			$newSize = sizeToFitSize($mw, $mh, $w, $h);
			$params['w'] = $newSize[0];
			$params['h'] = $newSize[1];
			$params['fit'] = 'scale';

			unset($params['fp-x']);
			unset($params['fp-y']);
			unset($params['fp-z']);
		}

		unset($params['focalpoint']);
		unset($params['faceindex']);

		if($mergeParams && is_array($mergeParams)) {
			$params = array_merge($params, $mergeParams);
		}

		if($size && !is_array($size)) {
			$params['wpsize'] = $size;
		}

		$params = $this->buildImgixParams($params, $mimetype);
		$params = apply_filters('ilab-imgix-filter-parameters', $params, $size, $id, $meta);

		$imageFile = (isset($meta['s3'])) ? $meta['s3']['key'] : $meta['file'];

		$result = [
			$imgix->createURL(str_replace('%2F', '/', urlencode($imageFile)), $params),
			$params['w'],
			$params['h'],
			true
		];

		return $result;
	}
352929
public function getCssFiles($controller_id, $template_id)
    {
        $css_files = [];
        $asset_config = $this->getConfigByName('assets');
        if (isset($asset_config[$controller_id][$template_id]['css'])) {
            $css_files = $asset_config[$controller_id][$template_id]['css'];
        }
        return $css_files;
    }
54579
public static function get_thumbnail_size() {
		$sizes = self::get_image_sizes();

		if ( isset( $sizes['thumbnail'] ) ) {
			return $sizes['thumbnail'];
		}

		$img_size = reset( $sizes );

		return $img_size;
	}
1328881
public static function getAcceptImageMimeTypes()
    {
        $imageAllowFiles = Yii::$app->getSettings()->get('imageAllowFiles','attachment');
        $extensions = explode(',', $imageAllowFiles);
        array_walk($extensions, function (&$value) {
            $value = 'image/' . $value;
        });
        return $extensions;
    }
966863
public function resolveCropResizeDimensions(Image $image, $width, $height)
    {
        if ($height > $width * ($image->height() / $image->width())) {
            return [$height * ($image->width() / $image->height()), $height];
        }

        return [$width, $width * ($image->height() / $image->width())];
    }
1048373
function image_resize( $file, $max_w, $max_h, $crop = false, $far = false, $iar = false, $dest_path = null, $jpeg_quality = 90 ) {
		$image = wp_load_image( $file );
		if ( !is_resource( $image ) )
			return new WP_Error('error_loading_image', $image);

		$size = @getimagesize( $file );
		if ( !$size )
				return new WP_Error('invalid_image', __('Could not read image size'), $file);
		list($orig_w, $orig_h, $orig_type) = $size;
		
		$dims = mf_image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop, $far, $iar);
		
		if ( !$dims ){
			$dims = array(0,0,0,0,$orig_w,$orig_h,$orig_w,$orig_h);
		}
		list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;

    $newimage = imagecreatetruecolor( $dst_w, $dst_h );
    imagealphablending($newimage, false);
    imagesavealpha($newimage, true);
    $transparent = imagecolorallocatealpha($newimage, 255, 255, 255, 127);
    imagefilledrectangle($newimage, 0, 0, $dst_w, $dst_h, $transparent);
    imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);

		// convert from full colors to index colors, like original PNG.
		if ( IMAGETYPE_PNG == $orig_type && !imageistruecolor( $image ) )
			imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) );

		// we don't need the original in memory anymore
		imagedestroy( $image );
		$info = pathinfo($dest_path);
		$dir = $info['dirname'];
		$ext = $info['extension'];
		$name = basename($dest_path, ".{$ext}");
		
		$destfilename = "{$dir}/{$name}.{$ext}";
		
		if ( IMAGETYPE_GIF == $orig_type ) {
 			if ( !imagegif( $newimage, $destfilename ) )
				return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
		} elseif ( IMAGETYPE_PNG == $orig_type ) {
			if ( !imagepng( $newimage, $destfilename ) )
				return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
		} else {
			// all other formats are converted to jpg
                  //Todo: add option for use progresive JPG
                  //imageinterlace($newimage, true); //Progressive JPG 
                  if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) )
                    return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
		}

		imagedestroy( $newimage );

		// Set correct file permissions
		$stat = stat( dirname( $destfilename ));
		$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
		@ chmod( $destfilename, $perms );

		return $destfilename;
	}
1177452
private function image_sizes_differ( $image_sizes, $meta_sizes ) {
		// Check if have new image size(s).
		if ( array_diff( array_keys( $image_sizes ), array_keys( $meta_sizes ) ) ) {
			return true;
		}
		// Check if image sizes have changed.
		foreach ( $image_sizes as $name => $image_size ) {
			if ( $image_size['width'] !== $meta_sizes[ $name ]['width'] || $image_size['height'] !== $meta_sizes[ $name ]['height'] ) {
				return true;
			}
		}
		return false;
	}
768871
public static function is_size_for_post_type( $img_size, $attachment_post_type ) {
		if ( ! is_array( $attachment_post_type ) ) {
			$attachment_post_type = array( $attachment_post_type );
		}

		// Reset post types that should be applied as a standard
		$post_types_to_apply = array( '', 'page', 'post' );

		/**
		 * When a post type is given in the arguments, we generate the size
		 * only if the attachment is associated with that post.
		 */
		if ( array_key_exists( 'post_types', $img_size ) ) {
			$post_types_to_apply = $img_size['post_types'];
		}

		if ( ! in_array( 'all', $post_types_to_apply, true ) ) {
			// Check if we should really resize that picture
			$intersections = array_intersect( $post_types_to_apply, $attachment_post_type );

			if ( ! empty( $intersections ) ) {
				return true;
			}
		} else {
			return true;
		}

		return false;
	}
113656
public function create(WP_Post $attachment, Size $size): Source
    {
        if (!wp_attachment_is_image($attachment)) {
            throw new InvalidArgumentException('Attachment must be an image.');
        }

        $imageSource = (array)wp_get_attachment_image_src(
            $attachment->ID,
            [$size->width(), $size->height()]
        );
        $imageSource = array_filter($imageSource);

        if (!$imageSource) {
            throw new DomainException(
                sprintf('Image with ID: %d, no longer exists', $attachment->ID)
            );
        }

        return new Source(...$imageSource);
    }
449667
public static function generateAvatarMarkup($user_id)
    {
        $filetypes = ['jpg', 'gif', 'png'];
        $avatar_markup = '';

        foreach ($filetypes as $cur_type) {
            $path = ForumSettings::get('o_avatars_dir') . '/' . $user_id . '.' . $cur_type;

            if (file_exists(ForumEnv::get('WEB_ROOT') . $path) &&
                $img_size = getimagesize(ForumEnv::get('WEB_ROOT') . $path)
            ) {
                $avatar_markup = '<img class="avatar" src="' .
                    \RunBB\Core\Utils::escape(Container::get('url')->base() . $path . '?m=' .
                        filemtime(ForumEnv::get('WEB_ROOT') . $path)) . '" ' . $img_size[3] . ' alt="" />';
                break;
            }
        }

        return $avatar_markup;
    }
949939
public static function get_dimensions_for_srcset_size( $resize, $srcset_size ) {
		// Get width and height for the additional src
		if ( is_array( $srcset_size ) ) {
			$width  = $srcset_size[0];
			$height = isset( $srcset_size[1] ) ? $srcset_size[1] : 0;
		} else {
			$width  = (int) round( $resize[0] * $srcset_size );
			$height = isset( $resize[1] ) ? (int) round( $resize[1] * $srcset_size ) : 0;
		}

		return array( $width, $height );
	}
1313737
public function generateAttachmentMetadata($metadata, $attachment_id) {
		if(!$this->enabledAlternativeFormats) {
			return $metadata;
		}

		$mime = get_post_mime_type($attachment_id);
		if($mime == 'application/vnd.adobe.illustrator') {
			$file = get_attached_file($attachment_id);
			$fileName = pathinfo($file, PATHINFO_BASENAME);
			$fallback_sizes = array(
				'thumbnail',
				'medium',
				'medium_large',
				'large',
			);
			$fallback_sizes = apply_filters('fallback_intermediate_image_sizes', $fallback_sizes, $metadata);
			$additional_sizes = wp_get_additional_image_sizes();

			$metadata = [
				'sizes' => [
					'full' => [
						'file' => $fileName,
						'width' => null,
						'height' => null,
						'mime-type' => 'image/jpeg'
					]
				]
			];

			foreach($fallback_sizes as $sz) {
				$metadata['sizes'][$sz] = [
					'file' => $fileName,
					'width' => get_option("{$sz}_size_w"),
					'height' => get_option("{$sz}_size_h"),
					'mime-type' => 'image/jpeg'
				];
			}

			foreach($additional_sizes as $size => $sizeInfo) {
				if(isset($sizeInfo['crop']) && $sizeInfo['crop']) {
					$metadata['sizes'][$size] = [
						'file' => $fileName,
						'width' => $sizeInfo['width'],
						'height' => $sizeInfo['height'],
						'mime-type' => 'image/jpeg'
					];
				}
			}

			$upload_info = wp_upload_dir();
			$upload_path = $upload_info['basedir'];
			$metadata['file'] = trim(str_replace($upload_path, '', $file), '/');
		}

		return $metadata;
	}
703720
public static function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale)
    {
        $newImageWidth = ceil($width * $scale);
        $newImageHeight = ceil($height * $scale);
        $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
        $source = imagecreatefromjpeg($image);
        imagecopyresampled($newImage, $source, 0, 0, $start_width, $start_height, $newImageWidth, $newImageHeight, $width, $height);
        imagejpeg($newImage, $thumb_image_name, 90);
        chmod($thumb_image_name, 0777);

        return $thumb_image_name;
    }
561425
public static function getImageSizes( $unset_disabled = true ) {
		$wais  = &$GLOBALS['_wp_additional_image_sizes'];
		$sizes = [];
		foreach ( get_intermediate_image_sizes() as $_size ) {
			if ( in_array( $_size, ['thumbnail', 'medium', 'medium_large', 'large'] ) ) {
				$sizes[ $_size ] = [
					'width'  => get_option("{$_size}_size_w"),
					'height' => get_option("{$_size}_size_h"),
					'crop'   => (bool) get_option("{$_size}_crop"),
				];
			} elseif ( $wais[ $_size ] ) {
				$sizes[ $_size ] = [
					'width'  => $wais[ $_size ]['width'],
					'height' => $wais[ $_size ]['height'],
					'crop'   => $wais[ $_size ]['crop'],
				];
			}
			// size registered, but has 0 width and height
			if ( $unset_disabled && ( $sizes[ $_size ]['width'] == 0 ) && ( $sizes[ $_size ]['height'] == 0 ) ) {
				unset( $sizes[ $_size ] );
			}
		}

		return $sizes;
	}