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

image URL is double encoded #23

Closed
fritzmg opened this issue Feb 13, 2018 · 8 comments
Closed

image URL is double encoded #23

fritzmg opened this issue Feb 13, 2018 · 8 comments
Assignees
Labels

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Feb 13, 2018

If the path to the social image is

files/content/FALTER_Scheckübergabe 2018 (c) Karin Wasner.jpeg

for example, the resulting og:image URL will be

https://example.org/files/content/FALTER_Scheck%25C3%25BCbergabe%25202018%2520%2528c%2529%2520Karin%2520Wasner.jpeg

i.e. the URL is double encoded. The correct URL would be

https://example.org/files/content/FALTER_Scheck%C3%BCbergabe%202018%20%28c%29%20Karin%20Wasner.jpeg

Tested in Contao 4.4.13 with Social Images 3.5.2.

@qzminski qzminski added the bug label Feb 13, 2018
@qzminski qzminski self-assigned this Feb 13, 2018
@qzminski
Copy link
Member

Hm I have set up the filename as you suggested but it seems to work fine for me:

<meta property="og:image" content="http://tmp:8888/files/test/FALTER_Scheck%C3%BCbergabe%202018%20%28c%29%20Karin%20Wasner.jpg">

Can you find out which module includes this image (core, news, etc.) ?

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 14, 2018

It's from a news list (image of the first news in the list on that page).

@qzminski
Copy link
Member

I am still unable to reproduce that on MacOS 🙈 can you find out the fix for yourself?

Is the image size calculated correctly? If it's double encoded then it should not work either...

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 15, 2018

Yeah, I'll debug :)

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 15, 2018

Ah, you need to set an image size in the page layout for the social images. \Image::get already encodes the image path. That's why it gets double encoded (even when it's not actually resized of course).

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 15, 2018

I'd propose the following:

    // Resize the image
    if ($resize[0] || $resize[1] || $resize[2]) {
-       $strImage = \Image::get($strImage, $resize[0], $resize[1], $resize[2]);
+       $strImage = urldecode(\Image::get($strImage, $resize[0], $resize[1], $resize[2]));
-       list($width, $height) = getimagesize(TL_ROOT . '/' . urldecode($strImage));
+       list($width, $height) = getimagesize(TL_ROOT . '/' . $strImage);
    }

@qzminski
Copy link
Member

I was about to write exactly the same. Thanks, I will fix this soon!

@qzminski
Copy link
Member

3.5.3 is released now.

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

2 participants