• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / Yoast-SEO-for-TYPO3 / 13327579701

14 Feb 2025 10:43AM UTC coverage: 1.276%. First build
13327579701

push

github

web-flow
Merge pull request #597 from Yoast/feature/v11

[FEATURE] Release 11.0.0

21 of 894 new or added lines in 76 files covered. (2.35%)

35 of 2744 relevant lines covered (1.28%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/MetaTag/Generator/AbstractGenerator.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\MetaTag\Generator;
6

7
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
8
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
9
use TYPO3\CMS\Core\Resource\FileInterface;
10
use TYPO3\CMS\Core\Resource\FileReference;
11
use TYPO3\CMS\Core\Resource\ProcessedFile;
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
use TYPO3\CMS\Extbase\Service\ImageService;
14

15
abstract class AbstractGenerator implements GeneratorInterface
16
{
17
    public function __construct(
18
        protected MetaTagManagerRegistry $managerRegistry
NEW
19
    ) {}
×
20

21
    /**
22
     * @see \TYPO3\CMS\Seo\MetaTag\MetaTagGenerator
23
     * @param FileReference[] $fileReferences
24
     * @return array<array{url: string, width: float, height: float, alternative: string}>
25
     */
26
    protected function generateSocialImages(array $fileReferences): array
27
    {
28
        $imageService = GeneralUtility::makeInstance(ImageService::class);
×
29

30
        $socialImages = [];
×
31

NEW
32
        foreach ($fileReferences as $fileReference) {
×
NEW
33
            $arguments = $fileReference->getProperties();
×
NEW
34
            $image = $this->processSocialImage($fileReference);
×
35
            $socialImages[] = [
×
NEW
36
                'url' => $imageService->getImageUri($image, true),
×
NEW
37
                'width' => floor((float)$image->getProperty('width')),
×
NEW
38
                'height' => floor((float)$image->getProperty('height')),
×
39
                'alternative' => $arguments['alternative'],
×
40
            ];
×
41
        }
42

43
        return $socialImages;
×
44
    }
45

46
    protected function processSocialImage(FileReference $fileReference): FileInterface
47
    {
NEW
48
        $arguments = $fileReference->getProperties();
×
NEW
49
        $cropVariantCollection = CropVariantCollection::create((string)($arguments['crop'] ?? ''));
×
NEW
50
        $cropVariantName = ($arguments['cropVariant'] ?? false) ?: 'social';
×
NEW
51
        $cropArea = $cropVariantCollection->getCropArea($cropVariantName);
×
NEW
52
        $crop = $cropArea->makeAbsoluteBasedOnFile($fileReference);
×
53

NEW
54
        $processingConfiguration = [
×
NEW
55
            'crop' => $crop,
×
NEW
56
            'maxWidth' => 2000,
×
NEW
57
        ];
×
58

59
        // The image needs to be processed if:
60
        //  - the image width is greater than the defined maximum width, or
61
        //  - there is a cropping other than the full image (starts at 0,0 and has a width and height of 100%) defined
NEW
62
        $needsProcessing = $fileReference->getProperty('width') > $processingConfiguration['maxWidth']
×
NEW
63
            || !$cropArea->isEmpty();
×
NEW
64
        if (!$needsProcessing) {
×
NEW
65
            return $fileReference->getOriginalFile();
×
66
        }
67

NEW
68
        return $fileReference->getOriginalFile()->process(
×
NEW
69
            ProcessedFile::CONTEXT_IMAGECROPSCALEMASK,
×
NEW
70
            $processingConfiguration
×
NEW
71
        );
×
72
    }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc