getCreateThumbnails example

static::assertNotNull($config);
    }

    private function assertConfig(
        MediaFolderEntity $folder,
        bool $useParentConfiguration,
        bool $createThumbnails,
        bool $keepAspectRatio,
        int $thumbnailQuality
    ): void {
        static::assertEquals($useParentConfiguration$folder->getUseParentConfiguration());
        static::assertEquals($createThumbnails$folder->getConfiguration()?->getCreateThumbnails());
        static::assertEquals($keepAspectRatio$folder->getConfiguration()?->getKeepAspectRatio());
        static::assertEquals($thumbnailQuality$folder->getConfiguration()?->getThumbnailQuality());
    }

    private function assertConfigIsSame(MediaFolderEntity $folder, MediaFolderEntity $childFolder): void
    {
        static::assertEquals($folder->getConfigurationId()$childFolder->getConfigurationId());
    }
}
$criteria = new Criteria();
        $criteria->addAssociation('configuration');

        $collection = $mediaFolderRepository->search($criteria$context)->getEntities();

        /** @var MediaFolderEntity $mediaFolder */
        $mediaFolder = $collection->get($folderId);

        static::assertEquals('default folder', $mediaFolder->getName());
        static::assertNotNull($mediaFolder->getConfigurationId());
        static::assertNotNull($mediaFolder->getConfiguration());
        static::assertTrue($mediaFolder->getConfiguration()->getCreateThumbnails());
    }

    public function testCreatedMediaFolderIsSetInConfiguration(): void
    {
        $context = Context::createDefaultContext();
        $mediaFolderRepository = $this->getContainer()->get('media_folder.repository');

        $folderId = Uuid::randomHex();
        $configurationId = Uuid::randomHex();

        $mediaFolderRepository->upsert([
            [
if (!$this->thumbnailsAreGeneratable($media)) {
            return false;
        }

        $this->ensureConfigIsLoaded($media$context);

        if ($media->getMediaFolder() === null || $media->getMediaFolder()->getConfiguration() === null) {
            return false;
        }

        return $media->getMediaFolder()->getConfiguration()->getCreateThumbnails();
    }

    private function thumbnailsAreGeneratable(MediaEntity $media): bool
    {
        return $media->getMediaType() instanceof ImageType
            && !$media->getMediaType()->is(ImageType::VECTOR_GRAPHIC)
            && !$media->getMediaType()->is(ImageType::ANIMATED)
            && !$media->getMediaType()->is(ImageType::ICON);
    }

    private function deleteAssociatedThumbnails(MediaEntity $media, Context $context): void
    {
$thumbnailHighDpiQuality = $data['thumbnailHighDpiQuality'] ?? 70;

        $albumId = $album->getId();
        if (empty($albumId) && $data['parent'] !== null) {
            /** @var Settings $parentSettings */
            $parentSettings = $data['parent']->getSettings();

            $thumbnailSizes = $parentSettings->getThumbnailSize();
            $thumbnailHighDpi = $parentSettings->isThumbnailHighDpi();
            $thumbnailHighDpiQuality = $parentSettings->getThumbnailHighDpiQuality();
            $thumbnailQuality = $parentSettings->getThumbnailQuality();
            $createThumbnails = $parentSettings->getCreateThumbnails();
        }

        $settings->setCreateThumbnails($createThumbnails);
        $settings->setThumbnailSize(empty($thumbnailSizes) ? '' : $thumbnailSizes);
        $settings->setThumbnailHighDpi($thumbnailHighDpi);
        $settings->setThumbnailQuality($thumbnailQuality);
        $settings->setThumbnailHighDpiQuality($thumbnailHighDpiQuality);
        $settings->setIcon($icon);

        $data['settings'] = $settings;

        
/** * Creates the thumbnail files in the different sizes which configured in the album settings. */
    public function createAlbumThumbnails(Album $album)
    {
        // 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) {
            
Home | Imprint | This part of the site doesn't use cookies.