#87442Can't modify/overwrite og:image and twitter:image via TypoScript
Description
It is not possible to overwrite the meta tags via TypoScript.
So you can not create a TypoScript fallback with the media resources.
‘page.meta.og:image’ has no impact.
’page.meta.twitter:image’ can be set and will be overwritten, if you set an image with page settings (twitter_image).
But not the other way round.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 8
-
Richard Haeser commented and changed status
NewNeeds Feedback 02/02/19, 23:04 -
corbet dynie commented 02/04/19, 12:45
First thanks for the reply.
The repace property will only prioritize the replacing with a plugin.
You are not allowed to replace the values with typoscript.For example you can use the .field property to create a fallback.
This works:twitter:title.field = twitter_title // seo_title // title
But with “twitter:image” and “og:image” this will not work.
You are not allowed to change the cType.For example, this does not work:
twitter:image = IMAGE twitter:image { file { import.data = levelmedia:-1, slide treatIdAsReference = 1 import.listNum = 0 } }or
twitter:image.stdWrap.cObject = IMAGE twitter:image.stdWrap.cObject { file { import.data = levelmedia:-1, slide treatIdAsReference = 1 import.listNum = 0 } } -
Riccardo De Contardi changed status
Needs FeedbackNew 03/09/19, 21:35 -
Riny van Tiggelen commented and changed status
NewNeeds Feedback 04/03/19, 18:50I have setup the following pages:
- Root page with a twitter card image and 1 image in the resources
- 1 Subpage without any imagesI have tried out the following:
page.meta.twitter:image.cObject = IMG_RESOURCE page.meta.twitter:image.cObject { file { import.data = levelmedia:-1, slide treatIdAsReference = 1 import.listNum = 0 } }On my homepage I see the twitter card image as twitter:image
On my subpage I see the resources-image from the homepage, as twitter:imageWhen I add a twitter card image to my subpage, that one is shown as twitter:image
When I add the following line:
page.meta.twitter:image.replace = 1
All the pages have the resources-image from the homepage.
What is exactly the preferred situation which is not possible at the moment?
-
Benni Mack changed target version 04/26/19, 21:26
-
Riccardo De Contardi commented 09/24/19, 13:06
I performed the following test on TYPO3 9.5.8
1) TS Setup:
page.meta.twitter:image.cObject = IMG_RESOURCE page.meta.twitter:image.cObject { file { import.data = levelmedia:-1, slide treatIdAsReference = 1 import.listNum = 0 } } page.meta.og:image.cObject = IMG_RESOURCE page.meta.og:image.cObject { file { import.data = levelmedia:-1, slide treatIdAsReference = 1 import.listNum = 0 } }2) Create at least three pages: “Home page”, “Page 1” and “Page 2” (the latter two are subpages of “Home page”.
3) Home page > edit page > tab Resources > add a file (fileadmin/test1.png)
4) Page 2 > edit page > tab Resources > add a file (fileadmin/test2.png)
5) Visit the three pages and look on the source code for the meta tags
Results:
Page image set on Resources Tab twitter:image meta content og:image meta content Home test1.png test1.png test1.png Page 1 none test1.png test1.png Page 2 test2.png test2.png test2.png Note
I tried to add to the TS Setup:
page.meta.twitter:image.replace = 1 page.meta.og:image.replace = 1
And the results are the same. Am I doing something wrong? Is this the expected result?
-
Riny van Tiggelen commented 04/06/20, 14:37
I’m sorry, to me this looks like the expected result. The typoscript provides the fallback so the image from the homepage is used on “Page 1” in your example.
Since Page 2 has an own image, this is the output.Could you clarify what the needed result is?
-
Richard Haeser commented and changed status
Needs FeedbackClosed 01/08/21, 15:18Closing this ticket because no feedback. If you want to override the meta tags with TypoScript, please use the replace property as documented in https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/MetaTagApi/Index.html#typoscript-and-php.
Hi,
did you check https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/MetaTagApi/Index.html#typoscript-and-php? Did you try the replace?
In my installation this is working fine.