removeAlbumThumbnails example

if ($isNameChanged) {
                // Remove default thumbnails                 $this->removeDefaultThumbnails($name);

                // Create default thumbnails                 $this->createDefaultThumbnails();
            }

            // 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);
            
/** * @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>> */
Home | Imprint | This part of the site doesn't use cookies.