getThumbnail example

case static::METADATA_ATTRIBUTE_NAME:
      case 'default_name':
        return $file->getFilename();

      case static::METADATA_ATTRIBUTE_MIME:
        return $file->getMimeType();

      case static::METADATA_ATTRIBUTE_SIZE:
        return $file->getSize();

      case 'thumbnail_uri':
        return $this->getThumbnail($file) ?: parent::getMetadata($media$attribute_name);

      default:
        return parent::getMetadata($media$attribute_name);
    }
  }

  /** * Gets the thumbnail image URI based on a file entity. * * @param \Drupal\file\FileInterface $file * A file entity. * * @return string * File URI of the thumbnail image or NULL if there is no specific icon. */

    public function getThumbnailsBySize($index)
    {
        $result = array_filter($this->media, function DMedia $media) {
            return $media->getType() === Media::TYPE_IMAGE;
        });

        return array_map(function DMedia $media) use ($index) {
            return $media->getThumbnail($index);
        }$result);
    }

    /** * @param Set $propertySet */
    public function setPropertySet($propertySet)
    {
        $this->propertySet = $propertySet;
    }

    

    public function installOrUpdate(array $presetMetaData)
    {
        $modelManager = $this->presetResource->getManager();

        /** @var PresetMetaDataInterface $metaData */
        foreach ($presetMetaData as $metaData) {
            $presetData = [
                'name' => $metaData->getName(),
                'premium' => $metaData->getPremium(),
                'custom' => $metaData->getCustom(),
                'thumbnail' => $metaData->getThumbnail(),
                'preview' => $metaData->getPreview(),
                'translations' => $metaData->getTranslations(),
                'presetData' => json_encode($metaData->getPresetData()),
                'requiredPlugins' => $metaData->getRequiredPlugins(),
                'assetsImported' => $metaData->getAssetsImported(),
            ];

            $slugifiedName = $this->slugService->slugify($metaData->getName());
            $preset = $modelManager->getRepository(Preset::class)->findOneBy(['name' => $slugifiedName]);

            if (!$preset) {
                
Home | Imprint | This part of the site doesn't use cookies.