getDefaultThumbnails example

if ($imageSize) {
                $media->setWidth($imageSize[0]);
                $media->setHeight($imageSize[1]);
            }

            $media->removeThumbnails();

            if ($newFileName) {
                $media->setPath($newFileName);
            }

            $this->thumbnailManager->createMediaThumbnail($media$media->getDefaultThumbnails(), true);
            $media->createAlbumThumbnails($media->getAlbum());
        } elseif ($newFileName) {
            $media->setPath($newFileName);
        }

        $this->modelManager->flush();
    }

    /** * @return string */
    

    public function createMediaThumbnail(Media $media$thumbnailSizes = []$keepProportions = false)
    {
        $imagePath = $media->getPath();

        if ($media->getType() !== $media::TYPE_IMAGE) {
            throw new Exception(sprintf('File %s is not an image.', $imagePath));
        }

        if (empty($thumbnailSizes)) {
            $thumbnailSizes = $this->getThumbnailSizesFromMedia($media);
            $thumbnailSizes = array_merge($thumbnailSizes$media->getDefaultThumbnails());
        }

        $albumSettings = $this->getAlbumSettingsFromMedia($media);
        if ($albumSettings) {
            $highDpi = $albumSettings->isThumbnailHighDpi();
            $standardQuality = $albumSettings->getThumbnailQuality();
            $highDpiQuality = $albumSettings->getThumbnailHighDpiQuality();
        } else {
            $highDpi = false;
            $standardQuality = 90;
            $highDpiQuality = 90;
        }

        // Is image media?         if ($this->type !== self::TYPE_IMAGE) {
            return;
        }

        // Check if the album has loaded correctly and should be created for the album thumbnails?         if ($album->getSettings() === null || !$album->getSettings()->getCreateThumbnails()) {
            return;
        }

        $defaultSizes = $this->getDefaultThumbnails();
        $defaultSize = implode('x', $defaultSizes[0]);
        // Load the configured album thumbnail sizes         $sizes = $album->getSettings()->getThumbnailSize();
        $sizes[] = $defaultSize;

        // Iterate the sizes and create the thumbnails         foreach ($sizes as $size) {
            // Split the width and height (example: $size = 70x70)             $data = explode('x', $size);

            // To avoid any confusing, we're mapping the index based to an association based array and remove the index based elements.
Home | Imprint | This part of the site doesn't use cookies.