WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#36899 closed defect (bug) (worksforme)

The srcset attribute (Responsive images) always returns the local URL of the file, not the URL on a CDN

Reported by: kameraadpjotr Owned by: joemcgill
Milestone: Priority: normal
Severity: normal Version: 4.5.2
Component: Media Keywords:
Focuses: Cc:
PR Number:

Description

My site uses Rackspace Cloud Files as CDN for its images, so no images are stored locally.

All this works fine (the src attribute is set correctly), but when wordpress creates the srcset attribute for responsive images, it uses the local path (https://www.example.com/wp-content/uploads/2016/05/thumbnail.jpg) and not the CDN path (https://files.rackspace.com/file/thumbnail.jpg).

Expected result: it returns the CDN path and not the local path.

Change History (2)

#1 @joemcgill
3 years ago

  • Owner set to joemcgill
  • Status changed from new to reviewing

Hi @kameraadpjotr,

Thanks for the report. If you're using a plugin to rewrite the image src attributes to point to your CDN, then you may need to get in touch with the plugin author about making sure the srcset attributes are also being rewritten. If you're handling this yourself, you can make use of the wp_calculate_image_srcset filter to convert all of the files in the srcset attribute to point to the files on your CDN.

#2 @joemcgill
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from reviewing to closed

Closing since I believe this will need to be handled by the CDN plugin, as described above.

Note: See TracTickets for help on using tickets.