isFormatSupported example


    private function migrateMeta(LifecycleEventArgs $eventArgs): void
    {
        $media = $eventArgs->getEntity();
        if (!$media instanceof Media) {
            return;
        }

        if (!$this->isFormatSupported($media)) {
            return;
        }

        $mediaService = $this->container->get(MediaServiceInterface::class);

        if ((!$media->getHeight() || !$media->getWidth()) && $mediaService->has($media->getPath())) {
            switch ($media->getType()) {
                case Media::TYPE_IMAGE:
                    $imageSize = getimagesizefromstring((string) $mediaService->read($media->getPath()));
                    if (\is_array($imageSize)) {
                        [$width$height] = $imageSize;
                        
Home | Imprint | This part of the site doesn't use cookies.