Closed qzminski closed 6 years ago
Imho you should add all 3 tags for one Image into one TL_HEAD entry
Allthough I agree with @backbone87 's comment, why do we use array_unique
here? Was this a fix for something else?
Regarding og/social images, it would be nice to have some abstraction for that. Contao modules itself add og tags in some places (e.g. image and description on a newsreader detail site) but the core does not support it by default in the BE (and that might be a good decisison). This is leaving opengraph extensions with the need to regex/tokenize the existing entries to eventually alter/overwrite them.
The array_unique is there because of modules and content elements adding tags multiple times. Imagine 5 elements on the same page, each adding a certain head tag. These tags (usually some script) should only be added once. Therefore we can not change this without having a big bc break.
Regarding og/social images, it would be nice to have some abstraction for that. Contao modules itself add og tags in some places (e.g. image and description on a newsreader detail site) but the core does not support it by default in the BE (and that might be a good decisison). This is leaving opengraph extensions with the need to regex/tokenize the existing entries to eventually alter/overwrite them.
There are some plans: https://github.com/contao/core/issues/8787#issuecomment-334469447
@backbone87 that's a good idea, I will use it!
@discordier at some point that is true but if you have N elements on the same page, it's likely that each of the scripts should check and overwrite a certain head tag. That's not the case here because for the array_unique()
function always the first occurrence of doubled item is preserved and the next are dropped. This might be a topic for a different discussion though.
I don't think we can do much about it; this is how array_unique()
works. And as @discordier explained, we cannot stop using it. You have to stick with @backbone87's solution.
The
TL_HEAD
tags that are being added to the page are first filtered out of duplicates. This is could be a problem for OpenGraph tags where you can define the arrays – http://ogp.me/#array.https://github.com/contao/core-bundle/blob/master/src/Resources/contao/library/Contao/Controller.php#L898
So if you would have two images and if their dimensions would be the same the output code should look like this:
But because the
array_unique
is called, some of the image size tags would be stripped:Contao 3 is affected as well. Also see https://github.com/codefog/contao-social_images/issues/19