Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contao 4.8 - not all possible og:image are generated #27

Closed
berecont opened this issue Oct 21, 2019 · 24 comments
Closed

Contao 4.8 - not all possible og:image are generated #27

berecont opened this issue Oct 21, 2019 · 24 comments
Assignees
Labels

Comments

@berecont
Copy link

Contao 4.8.4
codefog/contao-social_images 3.5.5
There is only the default image generated, choosen in site structure. If you don't choose one, there's no og:image generated.
Other images are not collected and generated as og:image in
the extension is activated in page layout.

this is both in a regular page an in the news page

@qzminski
Copy link
Member

How do you exactly add those images? For example, the image will not be considered if it is placed directly in the text editor (tinyMCE).

@berecont
Copy link
Author

no, not in the text editor ...
e.g. by mod_newslist or inside the mod_newsreader with galleries or single images (included by CE Image)

@qzminski
Copy link
Member

@fritzmg have you got a running system on that Contao version somewhere? 😇

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2019

I made a quick test in Contao 4.8 and I cannot confirm the problem. I inserted a ce_text with image and its image was inserted as an og:image in the <head>.

@qzminski
Copy link
Member

qzminski commented Nov 4, 2019

Thank you very much @fritzmg for checking this one! 🍻

@berecont have you got this system online and would you be able to provide me some access details for debugging?

@berecont
Copy link
Author

berecont commented Nov 4, 2019

https://wiewarsdort.at/
and you got email ...

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2019

https://wiewarsdort.at/

og:image is present there. Which settings are you using?

@berecont
Copy link
Author

berecont commented Nov 4, 2019

"... There is only the default image generated, choosen in site structure...."
for example: https://wiewarsdort.at/info/unterwegs-im-taffatal-horn-01-11-2019.html
there should be ALL gallery images generated, but it didn't

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2019

Which settings are you using?

@berecont
Copy link
Author

berecont commented Nov 4, 2019

  • site structure 'start of site' choosen an image
  • theme/layout:
    Social Images aktivieren
    Number of images 0
    Minimum width/height in pixels 200/200
    Resize dimensions (px) -

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2019

@qzminski while testing a gallery I indeed noticed an incompatibility with Contao 4.8:

ErrorException:
Warning: getimagesize(...\www\c48dev/assets/images/d/Deat_to_Stock_Goods_5-f9d29036.jpg): failed to open stream: No such file or directory

  at vendor/codefog/contao-social_images/classes/SocialImages.php:62
  at SocialImages\SocialImages->addSocialImages(object(PageModel), object(LayoutModel), object(PageRegular))
     (vendor/contao/core-bundle/src/Resources/contao/pages/PageRegular.php:191)
  at Contao\PageRegular->prepare(object(PageModel))
     (vendor/contao/core-bundle/src/Resources/contao/pages/PageRegular.php:48)
  at Contao\PageRegular->getResponse(object(PageModel), true)
     (vendor/contao/core-bundle/src/Resources/contao/controllers/FrontendIndex.php:343)
  at Contao\FrontendIndex->renderPage(object(PageModel))
     (vendor/symfony/http-kernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/index.php:31)
  at require('...\\www\\c48dev\\web\\index.php')
     (web/app.php:4)

Since Contao 4.8 we have deferred image resizing - however the social images extension wants to check the actual size of the image, before adding it as an og:image. At that time the image does not exist yet though.

@ausi can the target image size be retrieved somehow via a service?

@qzminski
Copy link
Member

qzminski commented Nov 4, 2019

Hey @ausi what would be the best option here: read maximum dimensions from corresponding JSON file, or somehow force to generate the image at a runtime?

@fritzmg
Copy link
Contributor

fritzmg commented Nov 4, 2019

or somehow force to generate the image at a runtime?

This would effectively negate the advantage of the deferred image resizing process of Contao 4.8+ whenever the social images extension is installed, since it will process the images of each image, text and gallery content element on each request.

@qzminski
Copy link
Member

qzminski commented Nov 4, 2019

@fritzmg that is true but I don't really see any other option as we have to know the real image size at the time page is being generated. If the image is deferred and does not exist, we'd either have to generate it or use the maximum image size set in the corresponding JSON file… that may be actually the best solution although it does not solve the problem in 100% as a small image wouldn't be upscaled and could be included despite the dimension limits.

@ausi
Copy link

ausi commented Nov 4, 2019

You can replace

list($width, $height) = getimagesize(TL_ROOT . '/' . $strImage);
and
list($width, $height) = getimagesize(TL_ROOT . '/' . $strImage);
with the following code:

list($width, $height) = (new \Contao\File($strImage))->imageSize;

This works with both, deferred and already resized images.

@qzminski
Copy link
Member

qzminski commented Nov 5, 2019

Thanks a lot @ausi 🍻

@qzminski qzminski removed the question label Nov 5, 2019
@qzminski qzminski self-assigned this Nov 5, 2019
@berecont
Copy link
Author

berecont commented Nov 5, 2019

sorry @qzminski , but after updating the package there's the same issue as before.
the update run with Contao Manager - 3.5.5 -> 3.5.6

@fritzmg
Copy link
Contributor

fritzmg commented Nov 5, 2019

@qzminski you forgot line 62 in SocialImages.php :)

@berecont
Copy link
Author

berecont commented Nov 5, 2019

but that isn't the solution (?)
I changed line 62 and the same issue as before

@fritzmg
Copy link
Contributor

fritzmg commented Nov 5, 2019

dev-hotfix/3.5.7 fixes my issue.

I otherwise cannot reproduce the issue of @berecont . I have added a text element with image plus a gallery on one page and got the following output in <head>:

<meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%282%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1279"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_1.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_10.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_2.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_3.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1279"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_4.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/assets/images/d/Deat_to_Stock_Goods_5-f9d29036.jpg">
<meta property="og:image:width" content="1024">
<meta property="og:image:height" content="1536"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_6.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_7.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_8.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Deat_to_Stock_Goods_9.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%281%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%2810%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%283%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%284%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%285%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1371"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%286%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%287%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1279"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%288%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280"><meta property="og:image" content="http://c48.local/files/dts/Death_to_stock_photography_weekend_work%20%289%20of%2010%29.jpg">
<meta property="og:image:width" content="1920">
<meta property="og:image:height" content="1280">

The first og:image is from the text content element, the rest of the images are from the gallery content element.

@qzminski
Copy link
Member

qzminski commented Nov 6, 2019

@berecont I have found the problem. You are inserting the news reader module as an insert tag which is generated after the og:image tags have been collected and added to the page. Try inserting the module as content element or directly as frontend module in page layout settings.

@berecont
Copy link
Author

berecont commented Nov 6, 2019

wow - ok, that's a problem I didn't know ...
I insert the module as a content element and all works right now.
thanks a lot!

@qzminski qzminski closed this as completed Nov 7, 2019
@fritzmg
Copy link
Contributor

fritzmg commented Nov 7, 2019

@qzminski will you release 3.5.7 soon? We actually use the extension in 2 live Contao 4.8 installations and the problem I discovered might occur there too.

@qzminski
Copy link
Member

qzminski commented Nov 7, 2019

Just released 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants