concrete/src/File/Image/Thumbnail/Type/Version.php
public function shouldExistFor($imageWidth, $imageHeight, File $file = null)
    {
        $result = false;
        $imageWidth = (int) $imageWidth;
        $imageHeight = (int) $imageHeight;
        if ($imageWidth > 0 && $imageHeight > 0) {
            // We have both image dimensions
            $thumbnailWidth = (int) $this->getWidth() ?: 0;
            $thumbnailHeight = (int) $this->getHeight() ?: 0;
            switch ($this->getSizingMode()) {
                case ThumbnailType::RESIZE_EXACT:
                    // Both the thumbnail width and height must be set
                    if ($thumbnailWidth > 0 && $thumbnailHeight > 0) {
                        // None of the thumbnail dimensions can be greater that image ones
                        if ($this->isUpscalingEnabled()) {
                            $result = true;
                        } else {
                            if ($thumbnailWidth <= $imageWidth && $thumbnailHeight <= $imageHeight) {
                                // Thumbnail must not be the same size as the image
                                if ($thumbnailWidth !== $imageWidth || $thumbnailHeight !== $imageHeight) {
                                    $result = true;
                                }
                            }
                        }
                    }
                    break;
                case ThumbnailType::RESIZE_PROPORTIONAL:
                default:
                    if ($thumbnailWidth > 0 || $thumbnailHeight > 0) {
                        if ($this->isUpscalingEnabled()) {
                            $result = true;
                        } else {
                            if ($thumbnailWidth > 0 && $thumbnailHeight > 0) {
                                // Both the thumbnail width and height are set
                                // At least one thumbnail dimension must be smaller that the corresponding image dimension
                                if ($thumbnailWidth < $imageWidth || $thumbnailHeight < $imageHeight) {
                                    $result = true;
                                }
                            } elseif ($thumbnailWidth > 0) {
                                // Only the thumbnail width is set: the thumbnail must be narrower than the image.
                                if ($thumbnailWidth < $imageWidth) {
                                    $result = true;
                                }
                            } elseif ($thumbnailHeight > 0) {
                                // Only the thumbnail height is set: the thumbnail must be shorter than the image.
                                if ($thumbnailHeight < $imageHeight) {
                                    $result = true;
                                }
                            }
                        }
                    }
                    break;
            }
            if ($result === true && $file !== null) {
                $fileSetIDs = $this->getAssociatedFileSetIDs();
                if ($this->isLimitedToFileSets()) {
                    // Thumbnail only if the file is in the specified file sets
                    if (empty($fileSetIDs)) {
                        $result = false;
                    } else {
                        $valid = array_intersect($fileSetIDs, $file->getFileSetIDs());
                        if (empty($valid)) {
                            $result = false;
                        }
                    }
                } else {
                    // Thumbnail only if the file is NOT in the specified file sets
                    if (!empty($fileSetIDs)) {
                        $blocking = array_intersect($fileSetIDs, $file->getFileSetIDs());
                        if (!empty($blocking)) {
                            $result = false;
                        }
                    }
                }
            }
        }

        return $result;
    }
public function shouldExistFor($imageWidth, $imageHeight, File $file = null)
    {
        $result = false;
        $imageWidth = (int) $imageWidth;
        $imageHeight = (int) $imageHeight;
        if ($imageWidth > 0 && $imageHeight > 0) {
            // We have both image dimensions
            $thumbnailWidth = (int) $this->getWidth() ?: 0;
            $thumbnailHeight = (int) $this->getHeight() ?: 0;
            switch ($this->getSizingMode()) {
                case ThumbnailType::RESIZE_EXACT:
                    // Both the thumbnail width and height must be set
                    if ($thumbnailWidth > 0 && $thumbnailHeight > 0) {
                        // None of the thumbnail dimensions can be greater that image ones
                        if ($this->isUpscalingEnabled()) {
                            $result = true;
                        } else {
                            if ($thumbnailWidth <= $imageWidth && $thumbnailHeight <= $imageHeight) {
                                // Thumbnail must not be the same size as the image
                                if ($thumbnailWidth !== $imageWidth || $thumbnailHeight !== $imageHeight) {
                                    $result = true;
                                }
                            }
                        }
                    }
                    break;
                case ThumbnailType::RESIZE_PROPORTIONAL:
                default:
                    if ($thumbnailWidth > 0 || $thumbnailHeight > 0) {
                        if ($this->isUpscalingEnabled()) {
                            $result = true;
                        } else {
                            if ($thumbnailWidth > 0 && $thumbnailHeight > 0) {
                                // Both the thumbnail width and height are set
                                // At least one thumbnail dimension must be smaller that the corresponding image dimension
                                if ($thumbnailWidth < $imageWidth || $thumbnailHeight < $imageHeight) {
                                    $result = true;
                                }
                            } elseif ($thumbnailWidth > 0) {
                                // Only the thumbnail width is set: the thumbnail must be narrower than the image.
                                if ($thumbnailWidth < $imageWidth) {
                                    $result = true;
                                }
                            } elseif ($thumbnailHeight > 0) {
                                // Only the thumbnail height is set: the thumbnail must be shorter than the image.
                                if ($thumbnailHeight < $imageHeight) {
                                    $result = true;
                                }
                            }
                        }
                    }
                    break;
            }
            if ($result === true && $file !== null) {
                $fileSetIDs = $this->getAssociatedFileSetIDs();
                if ($this->isLimitedToFileSets()) {
                    // Thumbnail only if the file is in the specified file sets
                    if (empty($fileSetIDs)) {
                        $result = false;
                    } else {
                        $valid = array_intersect($fileSetIDs, $file->getFileSetIDs());
                        if (empty($valid)) {
                            $result = false;
                        }
                    }
                } else {
                    // Thumbnail only if the file is NOT in the specified file sets
                    if (!empty($fileSetIDs)) {
                        $blocking = array_intersect($fileSetIDs, $file->getFileSetIDs());
                        if (!empty($blocking)) {
                            $result = false;
                        }
                    }
                }
            }
        }

        return $result;
    }
public function shouldExistFor ( $ imageWidth , $ imageHeight , File $ file = null ) { $ result = false ; $ imageWidth = ( int ) $ imageWidth ; $ imageHeight = ( int ) $ imageHeight ; if ( $ imageWidth > 0 && $ imageHeight > 0 ) { // We have both image dimensions $ thumbnailWidth = ( int ) $ this -> getWidth ( ) ? : 0 ; $ thumbnailHeight = ( int ) $ this -> getHeight ( ) ? : 0 ; switch ( $ this -> getSizingMode ( ) ) { case ThumbnailType :: RESIZE_EXACT : // Both the thumbnail width and height must be set if ( $ thumbnailWidth > 0 && $ thumbnailHeight > 0 ) { // None of the thumbnail dimensions can be greater that image ones if ( $ this -> isUpscalingEnabled ( ) ) { $ result = true ; } else { if ( $ thumbnailWidth <= $ imageWidth && $ thumbnailHeight <= $ imageHeight ) { // Thumbnail must not be the same size as the image if ( $ thumbnailWidth !== $ imageWidth || $ thumbnailHeight !== $ imageHeight ) { $ result = true ; } } } } break ; case ThumbnailType :: RESIZE_PROPORTIONAL : default : if ( $ thumbnailWidth > 0 || $ thumbnailHeight > 0 ) { if ( $ this -> isUpscalingEnabled ( ) ) { $ result = true ; } else { if ( $ thumbnailWidth > 0 && $ thumbnailHeight > 0 ) { // Both the thumbnail width and height are set // At least one thumbnail dimension must be smaller that the corresponding image dimension if ( $ thumbnailWidth < $ imageWidth || $ thumbnailHeight < $ imageHeight ) { $ result = true ; } } elseif ( $ thumbnailWidth > 0 ) { // Only the thumbnail width is set: the thumbnail must be narrower than the image. if ( $ thumbnailWidth < $ imageWidth ) { $ result = true ; } } elseif ( $ thumbnailHeight > 0 ) { // Only the thumbnail height is set: the thumbnail must be shorter than the image. if ( $ thumbnailHeight < $ imageHeight ) { $ result = true ; } } } } break ; } if ( $ result === true && $ file !== null ) { $ fileSetIDs = $ this -> getAssociatedFileSetIDs ( ) ; if ( $ this -> isLimitedToFileSets ( ) ) { // Thumbnail only if the file is in the specified file sets if ( empty ( $ fileSetIDs ) ) { $ result = false ; } else { $ valid = array_intersect ( $ fileSetIDs , $ file -> getFileSetIDs ( ) ) ; if ( empty ( $ valid ) ) { $ result = false ; } } } else { // Thumbnail only if the file is NOT in the specified file sets if ( ! empty ( $ fileSetIDs ) ) { $ blocking = array_intersect ( $ fileSetIDs , $ file -> getFileSetIDs ( ) ) ; if ( ! empty ( $ blocking ) ) { $ result = false ; } } } } } return $ result ; }
Check if this thumbnail type version should exist for an image with the specified dimensions.

@param int $imageWidth The original image width
@param int $imageHeight The original image height
@param File|null $file The File instance to check file sets against

@return bool
Check if this thumbnail type version should exist for an image with the specified dimensions .