setMediaType example

static::assertSame(0, $media->getThumbnails()?->count());
        static::assertTrue($this->getPublicFilesystem()->has($mediaUrl));
        foreach ($thumbnailUrls as $thumbnailUrl) {
            static::assertFalse($this->getPublicFilesystem()->has($thumbnailUrl));
        }
    }

    public function testThumbnailGenerationThrowsExceptionIfFileTypeIsNotImage(): void
    {
        $this->setFixtureContext($this->context);
        $media = $this->getPng();
        $media->setMediaType(new DocumentType());

        static::assertEquals(0, $this->thumbnailService->updateThumbnails(
            $media,
            $this->context,
            false
        ));
    }

    public function testThumbnailGenerationThrowsExceptionIfFileIsVectorGraphic(): void
    {
        $this->setFixtureContext($this->context);
        
foreach ($media->getThumbnails() ?? [] as $thumbnail) {
                $this->addThumbnailUrl($thumbnail$media);
            }
        }
    }

    public function unserialize(EntityLoadedEvent $event): void
    {
        /** @var MediaEntity $media */
        foreach ($event->getEntities() as $media) {
            if ($media->getMediaTypeRaw()) {
                $media->setMediaType(unserialize($media->getMediaTypeRaw()));
            }

            if ($media->getThumbnails() === null) {
                if ($media->getThumbnailsRo()) {
                    $media->setThumbnails(unserialize($media->getThumbnailsRo()));
                } else {
                    $media->setThumbnails(new MediaThumbnailCollection());
                }
            }
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.