getImage example


  protected function assertImageEffect(array $expected_operations, string $effect_name, array $data): void {
    $effect = $this->imageEffectPluginManager->createInstance($effect_name['data' => $data]);
    $image = $this->getImage();
    $this->imageTestReset();
    // The test toolkit does not actually implement the operation plugins,     // therefore the calls to TestToolkit::apply() will fail. That's not a     // problem here, we are not testing the actual operations.     $this->assertFalse($effect->applyEffect($image));
    $this->assertToolkitOperationsCalled($expected_operations);
  }

}
foreach ($mapping->getRules() as $rule) {
                $option = $rule->getOption();
                $alias = 'option' . $option->getId();
                $builder->innerJoin('variants.configuratorOptions', $alias, 'WITH', $alias . '.id = :' . $alias)
                    ->setParameter($alias$option->getId());
            }

            /** @var Query<Detail> $query */
            $query = $builder->getQuery();
            foreach ($query->getResult() as $variant) {
                if (!$force
                    && $this->getCollectionElementByProperty($variant->getImages(), 'parent', $mapping->getImage())
                ) {
                    continue;
                }

                $image = $this->getVariantResource()->createVariantImage(
                    $mapping->getImage(),
                    $variant
                );

                $variant->getImages()->add($image);
            }
        }

    public function make_subsize( $size_data ) {
        if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
            return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) );
        }

        $orig_size  = $this->size;
        $orig_image = $this->image->getImage();

        if ( ! isset( $size_data['width'] ) ) {
            $size_data['width'] = null;
        }

        if ( ! isset( $size_data['height'] ) ) {
            $size_data['height'] = null;
        }

        if ( ! isset( $size_data['crop'] ) ) {
            $size_data['crop'] = false;
        }
// set data to model and overwrite the image field         $supplierModel->fromArray($params);
        $supplierModel->setChanged();

        $mediaData = $this->Request()->get('media-manager-selection');
        if (!empty($mediaData)) {
            $supplierModel->setImage($this->Request()->get('media-manager-selection'));
        }

        // strip full qualified url         $mediaService = $this->get(MediaServiceInterface::class);
        $supplierModel->setImage($mediaService->normalize($supplierModel->getImage()));

        // backend checks         $name = $supplierModel->getName();
        if (empty($name)) {
            $this->View()->assign([
                'success' => false,
                'errorMsg' => 'No supplier name given',
            ]);

            return;
        }

        

        // Read data         $bannerModel->fromArray($params);

        // Set new image and extension if necessary         if (!empty($mediaManagerData)) {
            $bannerModel->setImage($mediaManagerData);
        }

        // Strip full qualified url         $mediaService = $this->get(MediaServiceInterface::class);
        $bannerModel->setImage($mediaService->normalize($bannerModel->getImage()));

        // Write model to db         try {
            $this->get('models')->persist($bannerModel);
            $this->get('models')->flush();
            $params['id'] = $bannerModel->getId();
            $this->View()->assign(['success' => 'true', 'data' => $params]);
        } catch (Exception $e) {
            $errorMsg = $e->getMessage();
            $this->View()->assign(['success' => 'false', 'errorMsg' => $errorMsg]);
        }
    }

  protected ImageEffectManager $imageEffectPluginManager;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->image = $this->getImage();
    $this->imageTestReset();
  }

  /** * Tests that the toolkit manager only returns available toolkits. */
  public function testGetAvailableToolkits() {
    $manager = $this->container->get('image.toolkit.manager');
    $toolkits = $manager->getAvailableToolkits();

    $this->assertArrayHasKey('test', $toolkits);
    
Home | Imprint | This part of the site doesn't use cookies.