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 encoded when used with Yoast SEO sitemaps #214

Open
timbolimboslice opened this issue Aug 10, 2023 · 0 comments
Open

Image URL is encoded when used with Yoast SEO sitemaps #214

timbolimboslice opened this issue Aug 10, 2023 · 0 comments

Comments

@timbolimboslice
Copy link

timbolimboslice commented Aug 10, 2023

Describe the bug
This is a continuation of the bug that was posted here. I'm using this plugin along with Yoast SEO and having issues with the image URLs when generating sitemaps. I can also kick this issue back to the Yoast team if that makes more sense. Tagging @jawngee since he was on that original issue.

Example entry in a sitemap:

<url>
      <loc>https://www.texasmonthly.dev/travel/where-to-stay-eat-retreat-east-texas/</loc>
      <lastmod>2023-04-13T17:44:33+00:00</lastmod>
      <image:image>
             <image:loc>https%3A%2F%2Fimg.texasmonthly.com%2F2021%2F06%2Ftyler-east-texas-guide-caddo-lake.jpg%3Fauto%3Dcompress%26crop%3Dfaces%26fit%3Dfit%26fm%3Dpjpg%26ixlib%3Dphp-3.3.1%26q%3D45</image:loc>
      </image:image>
</url>

I was able to work around this issue with the following code, but I think a solve within the plugin itself would be better long term.

add_filter( 'clean_url', array( $this, 'fix_sitemap_image_urls' ), 1001, 1 );

public function fix_sitemap_image_urls( $url ) {
    if ( strpos( $url, 'img.texasmonthly.com' ) !== false && strpos( $_SERVER['REQUEST_URI'], '.xml' ) !== false ) {
          return htmlspecialchars( urldecode( $url ) );
    }

    return $url;
}

To Reproduce

  • Setup Imgix bucket.
  • Install Yoast SEO
  • Check sitemap (/post-sitemap.xml)

Expected behavior
Image URLs used in Yoast SEO sitemaps should work without adding custom code.

How did you install the plugin?
via wordpress.org.

Additional context
Media Cloud (Premium) - version 4.5.20
Yoast SEO Premium - version 20.3
WordPress Core - version 6.1.1

Let me know if theres any I can do to assist. Thanks!

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

No branches or pull requests

1 participant