How to output og:image (sysext:seo) without cropping or processing? - typo3

If you store an Open Graph Image in the page properties, it will automatically be cropped to a ratio of 1.91 / 1 and even if you upload an image in exactly these proportions, it will still be reprocessed (and slightly trimmed).
I have already managed to get the cropping tool to accept a free ratio as the default:
/ext/sitepackage/Configuration/TCA/Overrides/pages.php
<?php
defined('TYPO3') or die();
$GLOBALS['TCA']['pages']['columns']['og_image']['config']['overrideChildTca']['columns']['crop']['config'] = [
'cropVariants' => [
'social' => [
'title' => 'Social media',
'cropArea' => [
'x' => '0.0',
'y' => '0.0',
'width' => '1.0',
'height' => '1.0'
],
'allowedAspectRatios' => [
'NaN' => [
'title' => 'Free',
'value' => 0.0
],
],
],
],
];
This creates the following entry in the database (sys_file_reference , column crop):
{"social":{"cropArea":{"x":0,"y":0,"width":1,"height":1},"selectedRatio":"NaN","focusArea":null}}
That looks fine to me.
Still, TYPO3 does not output my already optimized original image (fileadmin/media/1200x630.png) but one generated by the image processor (/fileadmin/processed/7/a/csm_….png , same pixel dimensions as the original). I have also manually removed the crop entry from the database as a test and still the URL of the original image is not output.
How can I prevent this?
Addendum: I created a bug report

The social images (open graph and twitter) are always processed. see https://github.com/TYPO3/typo3/blob/main/typo3/sysext/seo/Classes/MetaTag/MetaTagGenerator.php#L68.
You can create your own MetaTagManager for og:image, example is here: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/MetaTagApi/Index.html#creating-your-own-metatagmanager.
Don't know if that's a good way as there are special rules regarding dimensions of open graph images, see https://simplified.co/blog/design-hacks/open-graph-image-everything-you-need-to-know/

Related

TCA type 'inline' handling in multi language environment

The following scenario: I have a page translated (connected mode, not copy/free mode!) with multiple elements that are translated from the default language.
In my elements without inline fields everything is fine!
In my elements with inline fields I am completely confused about the handling and/or the configuration!
Let’s say I have a content element which contains three inline elements (let’s call them “quotes”). If I translate these quotes 1:1 everything works as expected.
Well ... almost:
I can create new quotes in the translation, but they won’t be displayed.
I can change the sorting, which won’t be taken into account in frontend. The frontend uses the sorting of the default language.
If I create a new quote in the default language, I get the record displayed in the translation and can translate it. So this works as expected.
This leads me to my questions:
How do I make it the quotes/inline elements in the translation independent of the default language?
If this is not possible (which would be fine to me, as it contradicts the idea of the Translate/Connected-Mode somehow) how do I get rid of the buttons for Sort and Create new (of cause only in the translation, not the default language!)? Otherwise, of course, editors try this and wonder why it doesn’t work.
I hope I’ve simply forget an option, but I’ve been thinking about it and looking for a solution for hours now that I probably can’t see the forest for the trees.
This might help if it is a missing option:
TCA
'config' => [
'appearance' => [
'collapseAll' => '1',
'enabledControls' => [
'dragdrop' => '1',
],
'levelLinksPosition' => 'bottom',
'newRecordLinkTitle' => 'New quote',
'useSortable' => '1',
'showSynchronizationLink' => true,
'showAllLocalizationLink' => true,
'showPossibleLocalizationRecords' => true,
],
'foreign_field' => 'parent_id',
'foreign_sortby' => 'sorting',
'foreign_table' => 'my_quotes_table',
'foreign_table_field' => 'parent_table',
'minitems' => '1',
'type' => 'inline',
],
Typoscript
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = my_quotes_field
table = my_quotes_table
pidInList.field = pid
where = parent_id=###uid### AND deleted=0 AND hidden=0
orderBy = sorting
markers.uid.field = uid
as = quotes
}
}
I am using TYPO3 version 11.5.17 with PHP 8.1 and MariaDB 10.5
1.How do I make it the quotes/inline elements in the translation independent of the default language?
You cannot (by any standard TYPO3 means) do this in connected mode. Your page needs to be in free-translation mode to do stuff like that.
If you want do hide the field for all the other languages you can add a "displayCond" property to your tca like this:
'displayCond' => [
'AND' => [
'FIELD:sys_language_uid:=:0'
]
],
This way the field at least stays hidden for the connected languages.

Add another picture to content element in typo3

I'm creating my own content element to display some text, some image and another image. This is my tt_content.php file.
'logo' => [
'label' => 'dfasad',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'logo',
[
'overrideChildTca' => [
'types' => [
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
'showitem' => '
--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
],
],
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],
This gives me an input field on the backend but it does not get saved on the db.
Probably I need to set that too, right?
I've seen the documentation but is not clear for, I can copy and paste the code and even if would work I would never know why.
You need to define a database field in the ext_tables.sql file of your extension.
CREATE TABLE mytablename (
logo int(11) DEFAULT '0' NOT NULL,
);
You need to set mytablename to the name of the table you're extending or your own table name.
See the documentation for details.

What's the best way to site specific configuration in a multisite TYPO3 installation?

We have a TYPO3 9.5 installation with a bunch of different websites in it.
We want to store some custom configurations for each site (eg. show phone number in footer yes/no and something like this) and give the editors the possibility to change this in a simple way in the backend.
It would be nice if we can store these properties on the rootpage of each site but be able to overwrite (some) properties on sub pages if needed.
Similar to the page properties that fluidtypo3/flux brings.
Is there a possibility to achieve this with TYPO3 core and a custom extension? Eg. by extending the page table or adding custom table?
You need to differ between a site configuration and regular pages!
The site configuration is valid for the full site, so for every page
A page can be different on a page level
Both use cases are valid, so let's explain in detail
Extending the site configuration
The site configuration can easily be extended by creating the file <site-extension>/Configuration/SiteConfiguration/Overrides/sites.php
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function ($table) {
$GLOBALS['SiteConfiguration'][$table]['columns']['trackingCode'] = [
'label' => 'Label',
'config' => [
'type' => 'input',
'eval' => 'trim',
'placeholder' => 'GTM-123456',
],
];
$GLOBALS['SiteConfiguration'][$table]['types']['0']['showitem'] .= ',--div--;Extra,trackingCode';
},
'site'
);
The value of the new field trackingCode can then be easily fetched, e.g. by TS with data = site:trackingCode. As an alternative you can also use the SiteProcessor to get access to the site configuration in a FLUIDTEMPLATE.
Extending pages
Create the file <site-extension>/Configuration/TCA/Overrides/pages.php
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'pages',
[
'trackingCode' => [
'exclude' => true,
'label' => 'A label',
'config' => [
'type' => 'input',
]
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'--div--;Extra, trackingCode'
);
and `ext_tables.sql``
CREATE TABLE pages (
trackingCode text NOT NULL
);
and you get access to the field with TypoScript and within FLUIDTEMPLATE with {data.trackingCode}.
Using slide
By adding trackingCode to the comma separated list in [FE][addRootLineFields] (use the Install Tool > Settings > Configure Installation-Wide Options it is possible to override the value for all subpages.
The following TypoScript will get up the rootline and return the 1st value set.
lib.code = TEXT
lib.code.data = levelfield:-1,trackingCode, slide

Drupal 8: Form API/Webforms: multiple composite field on same page with states

Help wanted
I'm struggling with the Form API/Webforms in Drupal 8.
I've made a couple of custom composite form elements that we use in a form. Some of the fields have a #states option. Here is a small example:
$elements['invoice_notice_of_default_file'] = [
'#type' => 'file',
'#title' => t('Voeg uw ingebrekestelling toe'),
'#states' => [
'visible' => [
':input[name="invoice_fields[invoice_notice_of_default]"]' => ['value' => 'yes'],
],
],
];
The problem with this is when I add more than 1 of the same composites on the same page, the name will have a number, like invoice_fields_2[invoice_notice_of_default], invoice_fields_3[invoice_notice_of_default]. This will break the states because of the hardcoded name. Anybody know what can be done about this?
Thanks in advance!!

Adding Headline and Text for Facebook Video Ads on API

Power editor allows you to add other fields like headline, and text, but the api is only limited to description for video ads. I tried to create a slideshow with a combination of images.
I actually tried, and it spins up error if I add the message, or caption field. Why is there a difference in the behaviour of power editor and api? Am I doing something wrong on my end?
The ad created via the api, with the empty fields on power editor.
Facebook official doc on video data -:
https://developers.facebook.com/…/r…/ad-creative-video-data/
My solution for this problem was to add a 'link_description' on the CALL_TO_ACTION value array (using a 'Learn More' CALL_TO_ACTION type).
My video data object looks like:
[
'title' => 'ADS HEADING',
'description' => 'ADS TEXT',
'image_url' => <URL TO IMAGE>,
'video_id' => <VIDEO_ID>,
'call_to_action' => [
'type' => 'LEARN_MORE',
'value' => [
'link' => <LINK>,
'link_caption' => <URL_CAPTION>,
'link_description' => 'ADS DESCRIPTION',
]
]
]
use name, title(only in video ad creatives), description.