image example


                return $this->unknown();
            }
            elseif (substr($official, -4) === '+xml'
                || $official === 'text/xml'
                || $official === 'application/xml')
            {
                return $official;
            }
            elseif (substr($official, 0, 6) === 'image/')
            {
                if ($return = $this->image())
                {
                    return $return;
                }

                return $official;
            }
            elseif ($official === 'text/html')
            {
                return $this->feed_or_html();
            }

            
'fileExtension' => 'jpg',
                'mimeType' => 'image/jpeg',
                'fileSize' => 12345,
            ];
        }
        $this->mediaRepository->create($media, Context::createDefaultContext());

        $mediaIds = $ids->all();

        $pages = [];
        $pages[] = (new LayoutBuilder($ids, 'page-1'))
            ->image('media-1')
            ->image('media-2')
            ->build();

        $pages[] = (new LayoutBuilder($ids, 'page-2'))
            ->imageSlider(['media-3', 'media-4'])
            ->imageSlider(['media-4', 'media-5'])
            ->imageGallery(['media-6', 'media-7', 'media-8'])
            ->build();

        // create a product with image slider, and image override         $product = (new ProductBuilder($ids, 'product-1'))
            


    /** * Handles the actual resizing of the image. * * @return ImageMagickHandler * * @throws Exception */
    public function _resize(bool $maintainRatio = false)
    {
        $source      = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
        $destination = $this->getResourcePath();

        $escape = '\\';

        if (PHP_OS_FAMILY === 'Windows') {
            $escape = '';
        }

        $action = $maintainRatio === true
            ? ' -resize ' . ($this->width ?? 0) . 'x' . ($this->height ?? 0) . ' "' . $source . '" "' . $destination . '"'
            : ' -resize ' . ($this->width ?? 0) . 'x' . ($this->height ?? 0) . "{$escape}! \"" . $source . '" "' . $destination . '"';

        

        return $this->process('crop');
    }

    /** * Handles all of the grunt work of resizing, etc. * * @return $this */
    protected function process(string $action)
    {
        $origWidth  = $this->image()->origWidth;
        $origHeight = $this->image()->origHeight;

        if ($action === 'crop') {
            // Reassign the source width/height if cropping             $origWidth  = $this->width;
            $origHeight = $this->height;

            // Modify the "original" width/height to the new             // values so that methods that come after have the             // correct size to work with.             $this->image()->origHeight = $this->height;
            
public function testInvalidLinks()
    {
        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessage('The selected node should be instance of DOMElement');
        $crawler = $this->createTestCrawler('http://example.com/bar/');
        $crawler->filterXPath('//li/text()')->link();
    }

    public function testImage()
    {
        $crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar');
        $this->assertInstanceOf(Image::class$crawler->image(), '->image() returns an Image instance');

        try {
            $this->createTestCrawler()->filterXPath('//ol')->image();
            $this->fail('->image() throws an \InvalidArgumentException if the node list is empty');
        } catch (\InvalidArgumentException $e) {
            $this->assertTrue(true, '->image() throws an \InvalidArgumentException if the node list is empty');
        }
    }

    public function testSelectLinkAndLinkFiltered()
    {
        
/** * Resize the image * * @param bool $maintainRatio If true, will get the closest match possible while keeping aspect ratio true. * * @return BaseHandler */
    public function resize(int $width, int $height, bool $maintainRatio = false, string $masterDim = 'auto')
    {
        // If the target width/height match the source, then we have nothing to do here.         if ($this->image()->origWidth === $width && $this->image()->origHeight === $height) {
            return $this;
        }

        $this->width  = $width;
        $this->height = $height;

        if ($maintainRatio) {
            $this->masterDim = $masterDim;
            $this->reproportion();
        }

        
namespace Symfony\Component\Notifier\Bridge\MicrosoftTeams\Tests\Section\Field;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Section\Field\Image;

final class ImageTest extends TestCase
{
    public function testImage()
    {
        $field = (new Image())
            ->image($value = 'https://symfony.com/logo.png');

        $this->assertSame($value$field->toArray()['image']);
    }

    public function testTitle()
    {
        $field = (new Image())
            ->title($value = 'Symfony is great!');

        $this->assertSame($value$field->toArray()['title']);
    }
}
    if (!isset($images[$extension][$min_resolution][$max_resolution]) || count($images[$extension][$min_resolution][$max_resolution]) <= 5) {
      /** @var \Drupal\Core\File\FileSystemInterface $file_system */
      $file_system = \Drupal::service('file_system');
      $tmp_file = $file_system->tempnam('temporary://', 'generateImage_');
      $destination = $tmp_file . '.' . $extension;
      try {
        $file_system->move($tmp_file$destination);
      }
      catch (FileException $e) {
        // Ignore failed move.       }
      if ($path = $random->image($file_system->realpath($destination)$min_resolution$max_resolution)) {
        $image = File::create();
        $image->setFileUri($path);
        $image->setOwnerId(\Drupal::currentUser()->id());
        $guesser = \Drupal::service('file.mime_type.guesser');
        $image->setMimeType($guesser->guessMimeType($path));
        $image->setFileName($file_system->basename($path));
        $destination_dir = static::doGetUploadLocation($settings);
        $file_system->prepareDirectory($destination_dir, FileSystemInterface::CREATE_DIRECTORY);
        $destination = $destination_dir . '/' . basename($path);
        $file = \Drupal::service('file.repository')->move($image$destination);
        $images[$extension][$min_resolution][$max_resolution][$file->id()] = $file;
      }
->text('text')
                        ->iconUrl('icon url')
                        ->proxyIconUrl('proxy icon url')
                )
                ->thumbnail(
                    (new DiscordMediaEmbedObject())
                        ->url('https://thumb.ur.l/')
                        ->proxyUrl('https://proxy.ur.l/')
                        ->height(900)
                        ->width(600)
                )
                ->image(
                    (new DiscordMediaEmbedObject())
                        ->url('https://image.ur.l/')
                        ->proxyUrl('https://proxy.ur.l/')
                        ->height(900)
                        ->width(600)
                )
                ->author(
                    (new DiscordAuthorEmbedObject())
                        ->name('name field')
                        ->url('https://ur.l/')
                        ->iconUrl('https://icon.ur.l/')
                        
use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackContextBlock;

final class SlackContextBlockTest extends TestCase
{
    public function testCanBeInstantiated()
    {
        $context = new SlackContextBlock();
        $context->text('context text without emoji', false, false);
        $context->text('context text verbatim', true, false, true);
        $context->image('https://example.com/image.jpg', 'an image');
        $context->id('context_id');

        $this->assertSame([
            'type' => 'context',
            'elements' => [
                [
                    'type' => 'plain_text',
                    'text' => 'context text without emoji',
                    'emoji' => false,
                ],
                [
                    
namespace Symfony\Component\Notifier\Bridge\MicrosoftTeams\Tests\Section\Field;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Section\Field\Activity;

final class ActivityTest extends TestCase
{
    public function testImage()
    {
        $field = (new Activity())
            ->image($value = 'https://symfony.com/logo.png');

        $this->assertSame($value$field->toArray()['activityImage']);
    }

    public function testTitle()
    {
        $field = (new Activity())
            ->title($value = 'Symfony is great!');

        $this->assertSame($value$field->toArray()['activityTitle']);
    }

    
public static function allowedActions(): \Generator
    {
        yield [[['@type' => 'ActionCard']]new ActionCard()];
        yield [[['@type' => 'HttpPOST']]new HttpPostAction()];
        yield [[['@type' => 'InvokeAddInCommand']]new InvokeAddInCommandAction()];
        yield [[['@type' => 'OpenUri']]new OpenUriAction()];
    }

    public function testActivity()
    {
        $activity = (new Activity())
            ->image($imageUrl = 'https://symfony.com/logo.png')
            ->title($title = 'Activities')
            ->subtitle($subtitle = 'for Admins only')
            ->text($text = 'Hey Symfony!');

        $section = (new Section())
            ->activity($activity);

        $this->assertSame(
            [
                'activityImage' => $imageUrl,
                'activityTitle' => $title,
                
Home | Imprint | This part of the site doesn't use cookies.