Project

General

Profile

Actions

Bug #87442

closed

Can't modify/overwrite og:image and twitter:image via TypoScript

Added by corbet dynie over 5 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
SEO
Start date:
2019-01-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

Actions #1

Updated by Richard Haeser about 5 years ago

  • Status changed from New to Needs Feedback

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.

Actions #2

Updated by corbet dynie about 5 years ago

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
    }
}

Actions #3

Updated by Riccardo De Contardi about 5 years ago

  • Status changed from Needs Feedback to New
Actions #4

Updated by Riny van Tiggelen about 5 years ago

  • Status changed from New to Needs Feedback

I have setup the following pages:
- Root page with a twitter card image and 1 image in the resources
- 1 Subpage without any images

I 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:image

When 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?

Actions #5

Updated by Benni Mack almost 5 years ago

  • Target version changed from next-patchlevel to Candidate for patchlevel
Actions #6

Updated by Riccardo De Contardi over 4 years ago

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?

Actions #7

Updated by Riny van Tiggelen about 4 years ago

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?

Actions #8

Updated by Richard Haeser over 3 years ago

  • Status changed from Needs Feedback to Closed

Closing 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.

Actions

Also available in: Atom PDF