createAlbumThumbnails example



            // Remove the configured album thumbnail files             $settings = $album->getSettings();
            if ($settings !== null) {
                $this->removeAlbumThumbnails($settings->getThumbnailSize()$name);
            }

            $this->updateAssociations();

            // Create album thumbnails             $this->createAlbumThumbnails($this->album);
        }

        // Name changed? Then rename the file and set the new path         if ($isNameChanged) {
            $mediaService = Shopware()->Container()->get(MediaServiceInterface::class);
            $newName = $this->getFileName();
            $newPath = $this->getUploadDir() . $newName;

            // Rename the file             $mediaService->rename($this->path, $newPath);

            

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        $this->force = (bool) $input->getOption('force');
        $this->errors = [];
        $this->generator = $this->getContainer()->get(Manager::class);

        $albumId = (int) $input->getOption('albumid');

        foreach ($this->getMediaAlbums($albumId) as $album) {
            $this->createAlbumThumbnails($album);
        }

        $this->printExitMessage();

        return 0;
    }

    /** * @param int $albumId * * @return Album[] */
/** * @throws Exception */
    private function createThumbnailsForMovedMedia(Media $media): void
    {
        $albumRepository = $this->get(ModelManager::class)->getRepository(Album::class);

        $album = $albumRepository->find($media->getAlbumId());

        if ($album instanceof Album) {
            $media->removeAlbumThumbnails($album->getSettings()->getThumbnailSize()$media->getFileName());
            $media->createAlbumThumbnails($album);
        }
    }

    /** * The internal toTree method iterates the given model and converts it into an array. * At the same time number of associated media is determined to the album. * If an album have sub-albums, the number of associated media of the sub-album added to the * media count of the parent album. * * @param array<string, mixed>|ArrayCollection $data * @param array<string, mixed>|null $parent * * @return array<int, array<string, mixed>> */
$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 */
    private function getExtension(UploadedFile $file)
    {
Home | Imprint | This part of the site doesn't use cookies.