Hi,

og:image "is invalid because it contains whitespace characters."
I think, if the whitespaces are replaced with %20, it resolves the issue.
Can we solve this issue, or a small hack is also good for me.

URL 'https://media.production.coolgift.com/s3fs-public/product/Can Bottle Crusher 1.jpg' for property 'og:image:url' of the object at 'https://www.coolgift.com/nl/Blikkenpers-en-Flessenpers-Deluxe' is invalid because it contains whitespace characters.

Check on https://developers.facebook.com/tools/debug/og/object/?q=https://www.coo...
Click on 'Fetch new scrape information'

Thanks

Comments

damienmckenna’s picture

Category: Bug report » Feature request
Priority: Major » Normal

I'm inclined to mark this as "won't fix" because you should be using Transliteration to simplify filenames anyway.

Jurgen8en’s picture

Thanks for your answer, that is the right way to do.

At the moment, I solved it like this:

function coolgift_html_head_alter(&$head_elements) {
//drupal_set_message('<pre>'.print_r($head_elements,1).'</pre>');
  if(isset($head_elements['metatag_og:image_0'])){
    $head_elements['metatag_og:image_0']['#value'] = str_replace(' ', '%20', $head_elements['metatag_og:image_0']['#value']);
  }
}
damienmckenna’s picture

Does it also work if you use the + symbol instead of %20?

akoepke’s picture

I have just encountered this same issue. For us using transliteration isn't an option as our images are stored in Amazon S3. The process to rename all existing 66,000 images which have spaces would take a very long time.

The site I manage is SSL only and we use the CDN module to rewrite image URLs. At the moment the URL going into the og:image tag is https:// which is causing issues with LinkedIn and Facebook. I have used the token for just the filename and manually added the correct domain to it but this causes issues when there are spaces in the file name.

damienmckenna’s picture

Title: og:image can not have whitespace » Replace spaces in URLs in image fields with %20 or a plus symbol

How about we set it up that all image URLs automatically have spaces replaced appropriately?

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new969 bytes

This might help, but we're at the point that we need some tests.

damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
damienmckenna’s picture

Status: Needs work » Needs review
Parent issue: » #2699045: Plan for Metatag 7.x-1.15 release
StatusFileSize
new8.65 KB

So I ended up just going with replacing spaces with the '%20' string, and then I added some extra assertions to make sure the URLs could be loaded.

Status: Needs review » Needs work

The last submitted patch, 8: metatag-n2539388-8.patch, failed testing.

The last submitted patch, 8: metatag-n2539388-8.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new8.65 KB

Weird, those two tests work locally. Trying again.

Status: Needs review » Needs work

The last submitted patch, 11: metatag-n2539388-11.patch, failed testing.

The last submitted patch, 11: metatag-n2539388-11.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new8.66 KB

Lets see what error is actually being thrown on lines 99 and 138.

Status: Needs review » Needs work

The last submitted patch, 14: metatag-n2539388-14.patch, failed testing.

The last submitted patch, 14: metatag-n2539388-14.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new8.69 KB

Lets see what the actual URL is.

Status: Needs review » Needs work

The last submitted patch, 17: metatag-n2539388-17.patch, failed testing.

The last submitted patch, 17: metatag-n2539388-17.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new9.29 KB

Lets try to get more detail.

Status: Needs review » Needs work

The last submitted patch, 20: metatag-n2539388-20.patch, failed testing.

The last submitted patch, 20: metatag-n2539388-20.patch, failed testing.

damienmckenna’s picture

StatusFileSize
new9.45 KB

Trying again.

damienmckenna’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: metatag-n2539388-23.patch, failed testing.

The last submitted patch, 23: metatag-n2539388-23.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new9.46 KB

Grumble.

Status: Needs review » Needs work

The last submitted patch, 27: metatag-n2539388-27.patch, failed testing.

The last submitted patch, 27: metatag-n2539388-27.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Fixed
StatusFileSize
new9.62 KB

Lets see if I can fix the handling of relative image paths too.

damienmckenna’s picture

Status: Fixed » Needs review
StatusFileSize
new9.54 KB

Another possible improvement to the relative path handling.

Status: Needs review » Needs work

The last submitted patch, 31: metatag-n2539388-31.patch, failed testing.

The last submitted patch, 31: metatag-n2539388-31.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new10.05 KB

Die, bugs, die.

Status: Needs review » Needs work

The last submitted patch, 34: metatag-n2539388-34.patch, failed testing.

The last submitted patch, 34: metatag-n2539388-34.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.44 KB

One more time, with feeling.

Status: Needs review » Needs work

The last submitted patch, 37: metatag-n2539388-37.patch, failed testing.

The last submitted patch, 37: metatag-n2539388-37.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.4 KB

Status: Needs review » Needs work

The last submitted patch, 40: metatag-n2539388-40.patch, failed testing.

The last submitted patch, 40: metatag-n2539388-40.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.41 KB

Status: Needs review » Needs work

The last submitted patch, 43: metatag-n2539388-43.patch, failed testing.

The last submitted patch, 43: metatag-n2539388-43.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.6 KB

Status: Needs review » Needs work

The last submitted patch, 46: metatag-n2539388-46.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new12 KB

Status: Needs review » Needs work

The last submitted patch, 48: metatag-n2539388-48.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.66 KB

Status: Needs review » Needs work

The last submitted patch, 50: metatag-n2539388-50.patch, failed testing.

damienmckenna’s picture

StatusFileSize
new12.26 KB
damienmckenna’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 52: metatag-n2539388-52.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new12.39 KB

Status: Needs review » Needs work

The last submitted patch, 55: metatag-n2539388-55.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.85 KB

Status: Needs review » Needs work

The last submitted patch, 57: metatag-n2539388-57.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new11.62 KB

  • DamienMcKenna committed 451f4b1 on 7.x-1.x
    Issue #2539388 by DamienMcKenna: All image meta tags will be output with...
damienmckenna’s picture

Status: Needs review » Fixed

Committed. And I've added a change notice for this: https://www.drupal.org/node/2731999

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.