eZ Platform Discussions

No space in image URL for facebook

Bonjour à tous,

I have set up metadata for Facebook.

<meta property="og:image" content="{{ ez_render_field(content, 'image', {'parameters': {'alias': 'large', 'url_only': true }}) }}" />

This render something like that :

<meta property="og:image" content="https://www.site.com/var/site/storage/images/_aliases/large/.../Frederic Passy.jpg" />

Frederic Passy.jpg is the original file name.

In most cases, having a space in the file name does not cause a problem.

But it’s on break for facebook who can’t get the image back…
( https://developers.facebook.com/tools/debug/sharing/ )

How can I manage this problem?

(Just deleting or replacing spaces is not enough…
https://www.site.com/var/site/storage/images/_aliases/large/.../Frederic-Passy.jpg => 404)

Merci :slight_smile:

Hi @remy_php

Did you try removing the image from the field, publishing the content and then adding the image again with the correct name?

Yes, the manual modification of the file name works.

But I have 50,000 items. I don’t know which ones need to be corrected.
And I have contributors who can (even if they are told not to) add new images with junk in the filenames…

A solution might be to rename to upload?

Hi @remy_php!

Why not using url_encode?
https://twig.symfony.com/doc/2.x/filters/url_encode.html

As far as I understood, that’s what eZ kernel should use before storing the file. That’s the whole issue.

I checked on Jira and I found this ticket https://jira.ez.no/browse/EZP-29592 (related PR: https://github.com/ezsystems/ezpublish-kernel/pull/2442)

@bdunogier could you please look into this topic?