Jack Pilowsky
Jack Pilowsky

Reputation: 2303

Facebook open graph og:image escape whitespace characters

I have a page with user submitted photo galleries. I'm using the facebook API to share the photos. It shares the page with a query string. When the query string is present, it sets all the open graph properties on the page . This works great except when the image has white space characters on the file name.

I have tried replacing the whitespace characters with '%20' as so

http://example.com/gallery/images/large/this image.jpg

to

 http://example.com/gallery/images/large/this%20image.jpg

But the facebook parser doesn't like that either.

Is there a way to scape these characters or am I going to have to go back and change it so that it replaces when the images get uploaded?

Upvotes: 1

Views: 2524

Answers (2)

Dharmang
Dharmang

Reputation: 3028

Answering your question (being it old), Now (in June-2017) Facebook parser works with whitespace characters when escaped with '%20', hope it would help someone looking for solution.

So, convert whitespace to %20 as depicted below:

http://example.com/gallery/images/large/this image.jpg

to

http://example.com/gallery/images/large/this%20image.jpg

Server side language has pre-defined function for that e.g. rawurlencode in PHP.

Upvotes: 1

lamdadj22
lamdadj22

Reputation: 126

I don't think so. The facebook parser doesn't take whitespaces into account. Even if you use a redirect you will have issues later on. So it's better to just adjust your URLs now.

Upvotes: 0

Related Questions