setHeight example

public function testItAddsThumbnailUrl(): void
    {
        $subscriber = $this->getContainer()->get(MediaLoadedSubscriber::class);
        $context = Context::createDefaultContext();

        $mediaId = '34556f108ab14969a0dcf9d9522fd7df';
        $mimeType = 'image/png';

        $thumbnailEntity = new MediaThumbnailEntity();
        $thumbnailEntity->setId($mediaId);
        $thumbnailEntity->setHeight(100);
        $thumbnailEntity->setWidth(100);

        $mediaEntity = new MediaEntity();
        $mediaEntity->setId($mediaId);
        $mediaEntity->setMimeType($mimeType);
        $mediaEntity->setFileExtension('png');
        $mediaEntity->setFileName($mediaId . '-134578345');
        $mediaEntity->setThumbnails(new MediaThumbnailCollection([$thumbnailEntity]));

        $mediaLoadedEvent = new EntityLoadedEvent($this->getContainer()->get(MediaDefinition::class)[$mediaEntity]$context);
        $subscriber->addUrls($mediaLoadedEvent);

        
'#uri' => $icon_path,
        '#width' => $width,
        '#height' => $height,
        '#alt' => $this->getLabel(),
      ];
    }
    elseif ($icon_map = $this->getIconMap()) {
      $icon_builder = $this->getIconBuilder()
        ->setId($this->id())
        ->setLabel($this->getLabel())
        ->setWidth($width)
        ->setHeight($height);
      if ($padding) {
        $icon_builder->setPadding($padding);
      }
      if ($stroke_width) {
        $icon_builder->setStrokeWidth($stroke_width);
      }
      $icon = $icon_builder->build($icon_map);
    }
    return $icon;
  }

  

        if ($this->isUpdateRequired($media$data)) {
            $data = $this->updateMedia($data);
        }

        if (isset($data['__media_width'])) {
            $media->setWidth((int) $data['__media_width']);
        }

        if (isset($data['__media_height'])) {
            $media->setHeight((int) $data['__media_height']);
        }

        if ($this->shouldAddThumbnails($media->getType()$data)) {
            $media->setThumbnails(
                $this->getMediaThumbnails($data)
            );
        }

        if (!empty($data['__mediaAttribute_id'])) {
            $this->attributeHydrator->addAttribute($media$data, 'mediaAttribute', 'media');
        }

        
$product->setHighlight($listProduct->highlight());
        $product->setUnit($listProduct->getUnit());
        $product->setTax($listProduct->getTax());
        $product->setPrices($listProduct->getPrices());
        $product->setManufacturer($listProduct->getManufacturer());
        $product->setCover($listProduct->getCover());
        $product->setCheapestPrice($listProduct->getCheapestPrice());
        $product->setName($listProduct->getName());
        $product->setAdditional($listProduct->getAdditional());
        $product->setCloseouts($listProduct->isCloseouts());
        $product->setEan($listProduct->getEan());
        $product->setHeight($listProduct->getHeight());
        $product->setKeywords($listProduct->getKeywords());
        $product->setLength($listProduct->getLength());
        $product->setLongDescription($listProduct->getLongDescription());
        $product->setMinStock($listProduct->getMinStock());
        $product->setReleaseDate($listProduct->getReleaseDate());
        $product->setShippingTime($listProduct->getShippingTime());
        $product->setShortDescription($listProduct->getShortDescription());
        $product->setStock($listProduct->getStock());
        $product->setWeight($listProduct->getWeight());
        $product->setWidth($listProduct->getWidth());
        $product->setPriceGroup($listProduct->getPriceGroup());
        
new DateTime($data['__product_datum'])
            );
        }
        if ($data['__product_changetime']) {
            $product->setUpdatedAt(
                new DateTime($data['__product_changetime'])
            );
        }

        $product->setAdditional($data['__variant_additionaltext']);
        $product->setEan($data['__variant_ean']);
        $product->setHeight((float) $data['__variant_height']);
        $product->setLength((float) $data['__variant_length']);
        $product->setMinStock((int) $data['__variant_stockmin']);
        $product->setWeight((float) $data['__variant_weight']);
        $product->setWidth((float) $data['__variant_width']);

        $customerGroups = explode('|', $data['__product_blocked_customer_groups'] ?? '');
        $customerGroups = array_filter($customerGroups);
        $product->setBlockedCustomerGroupIds($customerGroups);
        $product->setHasAvailableVariant($data['__product_has_available_variants'] > 0);

        $product->setFallbackPriceCount($data['__product_fallback_price_count']);
        


        $media->setExtension($this->getExtension($file));
        $media->setFileSize(filesize($filePath));
        $media->setCreated(new DateTime());

        if ($media->getType() === Media::TYPE_IMAGE) {
            $imageSize = getimagesize($filePath);

            if ($imageSize) {
                $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) {
            
$eventArgs->getEntityManager()->getConnection()->executeUpdate(
                        'UPDATE s_media SET width = :width, height = :height WHERE id = :id',
                        [
                            ':width' => $width,
                            ':height' => $height,
                            ':id' => $media->getId(),
                        ]
                    );
                }

                $media->setWidth($width);
                $media->setHeight($height);
            }
        }
    }

    /** * Test file for supported types */
    private function isFormatSupported(Media $media): bool
    {
        return $media->getType() === Media::TYPE_IMAGE
            || ($media->getType() === Media::TYPE_VECTOR && $media->getExtension() === 'svg');
    }
use Shopware\Core\Content\Media\Aggregate\MediaThumbnail\MediaThumbnailEntity;

/** * @internal */
class MediaThumbnailStructTest extends TestCase
{
    public function testGetIdentifier(): void
    {
        $thumbnail = new MediaThumbnailEntity();
        $thumbnail->setWidth(120);
        $thumbnail->setHeight(100);

        static::assertEquals('120x100', $thumbnail->getIdentifier());
    }
}
$data['empty'][] = (new SvgIconBuilder());
    $data['empty'][] = [];
    $data['empty'][] = <<<'EOD' <svg width="125" height="150" class="layout-icon"></svg> EOD;

    $data['two_column'][] = (new SvgIconBuilder())
      ->setId('two_column')
      ->setLabel('Two Column')
      ->setWidth(250)
      ->setHeight(300)
      ->setStrokeWidth(2);
    $data['two_column'][] = [['left', 'right']];
    $data['two_column'][] = <<<'EOD' <svg width="250" height="300" class="layout-icon layout-icon--two-column"><title>Two Column</title> <g><title>left</title> <rect x="1" y="1" width="121" height="298" stroke-width="2" class="layout-icon__region layout-icon__region--left" /> </g> <g><title>right</title> <rect x="128" y="1" width="121" height="298" stroke-width="2" class="layout-icon__region layout-icon__region--right" /> </g> </svg>
Home | Imprint | This part of the site doesn't use cookies.