Merge branch 'master' into develop
This commit is contained in:
@@ -2,44 +2,68 @@
|
||||
|
||||
namespace EP\EpTheme\MetaTag;
|
||||
|
||||
use TYPO3\CMS\Core\Resource\ResourceFactory;
|
||||
use TYPO3\CMS\Core\Resource\FileRepository;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Core\Utility\RootlineUtility;
|
||||
use TYPO3\CMS\Extbase\Service\ImageService;
|
||||
|
||||
class OpenGraphMetaTagManager extends \TYPO3\CMS\Seo\MetaTag\OpenGraphMetaTagManager
|
||||
{
|
||||
public function renderAllProperties(): string
|
||||
{
|
||||
if (!array_key_exists('og:image', $this->properties)) {
|
||||
/** @var ConfigurationManager $configurationManager */
|
||||
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
if (array_key_exists('og:image', $this->properties)) {
|
||||
return parent::renderAllProperties();
|
||||
}
|
||||
/** @var FileRepository $fileRepository */
|
||||
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
|
||||
|
||||
$pageUid = $this->getPageWithImage();
|
||||
|
||||
if (null === $pageUid) {
|
||||
return parent::renderAllProperties();
|
||||
}
|
||||
|
||||
$images = $fileRepository->findByRelation('pages', 'og_image', $pageUid);
|
||||
|
||||
/** @var ImageService $imageService */
|
||||
$imageService = GeneralUtility::makeInstance(ImageService::class);
|
||||
|
||||
foreach ($images as $image) {
|
||||
$processedImage = $imageService->applyProcessingInstructions(
|
||||
$image,
|
||||
[
|
||||
'width' => '1200'
|
||||
]
|
||||
);
|
||||
$this->addProperty(
|
||||
'og:image',
|
||||
$imageService->getImageUri($processedImage, true),
|
||||
[
|
||||
'url' => $imageService->getImageUri($processedImage, true),
|
||||
'width' => $processedImage->getProperty('width'),
|
||||
'height' => $processedImage->getProperty('height'),
|
||||
'type' => $processedImage->getMimeType(),
|
||||
]
|
||||
);
|
||||
$imageSource = $settings['plugin']['tx_eptheme']['settings']['ogDefaultImage'];
|
||||
$resourceFactory = ResourceFactory::getInstance();
|
||||
$image = $resourceFactory->getFileObjectFromCombinedIdentifier(sprintf('1:%s', $imageSource));
|
||||
|
||||
if (null !== $image) {
|
||||
/** @var ImageService $imageService */
|
||||
$imageService = GeneralUtility::makeInstance(ImageService::class);
|
||||
$processedImage = $imageService->applyProcessingInstructions($image, ['width' => '1200']);
|
||||
|
||||
$this->addProperty(
|
||||
'og:image',
|
||||
$imageService->getImageUri($processedImage, true),
|
||||
[
|
||||
'url' => $imageService->getImageUri($processedImage, true),
|
||||
'width' => $processedImage->getProperty('width'),
|
||||
'height' => $processedImage->getProperty('height'),
|
||||
'type' => $processedImage->getMimeType(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::renderAllProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
protected function getPageWithImage()
|
||||
{
|
||||
$rootLineUtility = new RootlineUtility($GLOBALS['TSFE']->id);
|
||||
$rootLine = $rootLineUtility->get();
|
||||
|
||||
foreach ($rootLine as $page) {
|
||||
if ($page['og_image'] > 0) {
|
||||
return $page['uid'];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -90,8 +90,6 @@ plugin.tx_eptheme {
|
||||
facebookViewContentProductUid =
|
||||
# cat=eptheme/100/150; type=string; label=Facebook ViewContent 'name internal'
|
||||
facebookViewContentNameInternal =
|
||||
# cat=eptheme/100/160; type=string; label=OG default image
|
||||
ogDefaultImage = user_upload/Open_Graph__Linkvorschau_/Home-Vorschaubild.jpg
|
||||
|
||||
# cat=eptheme; type=string; label=Slider storage PID
|
||||
sliderStoragePid =
|
||||
|
||||
@@ -94,7 +94,6 @@ plugin.tx_eptheme {
|
||||
productUid = {$plugin.tx_eptheme.settings.facebookViewContentProductUid}
|
||||
nameInternal = {$plugin.tx_eptheme.settings.facebookViewContentNameInternal}
|
||||
}
|
||||
ogDefaultImage = {$plugin.tx_eptheme.settings.ogDefaultImage}
|
||||
domainsToTrack = bpn.ep-reisen.de,www.ski-boarderweek.de,www.ski-wochenenden.de,www.snowzone.net,www.unichamp.de
|
||||
}
|
||||
view {
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
defined('TYPO3_MODE') or die();
|
||||
|
||||
call_user_func(function () {
|
||||
if ($GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] !== '') {
|
||||
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ',';
|
||||
}
|
||||
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= 'og_image';
|
||||
|
||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_eptheme_domain_model_slide');
|
||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_eptheme_domain_model_lineup');
|
||||
@@ -17,5 +21,4 @@ call_user_func(function () {
|
||||
['source' => 'EXT:ep_theme/Resources/Public/images/logo.svg']
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user