wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

404 errors on images using relative protocols, when Lazyload for CSS Background is enabled

Open alfonso100 opened this issue 1 year ago • 4 comments

Before submitting an issue please check that you’ve completed the following steps: yes - Made sure you’re on the latest version yes - Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug When relative protocols are used in the CSS, for image URLs, the resulting Background image in the JSON rocket_pairs will have an incorrect path, containing the URL twice:

CSS: background-image: url("//www.site.comp/wp-content/uploads/2023/03/image.jpg"); JSON path: https:\/\/www.site.com\/www.site.com\/wp-content\/uploads\/2023\/08\/image.jpg

Please note double URL in the JSON.

To Reproduce Steps to reproduce the behavior:

  1. Add a CSS bg image with relative protocol
  2. Enable Lazyload for Background CSS images
  3. See the 404 images

Expected behavior we should be able to handle relative protocols.

Screenshots Origin CSS: https://i.imgur.com/WlKBOfi.png result JSON: https://i.imgur.com/YCP90br.png

Additional context Ticket: https://secure.helpscout.net/conversation/2476111039/468216?folderId=2683093 Slack thread: https://wp-media.slack.com/archives/C43T1AYMQ/p1704917985182319

Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming

alfonso100 avatar Jan 15 '24 21:01 alfonso100

Related:

https://secure.helpscout.net/conversation/2683568038/508255/

Adrianadla avatar Aug 19 '24 17:08 Adrianadla

Related: https://secure.helpscout.net/conversation/2729007953/516740/

sandyfzu avatar Oct 08 '24 16:10 sandyfzu

Related: https://secure.helpscout.net/conversation/2754186609/521370

sandyfzu avatar Nov 05 '24 15:11 sandyfzu

Another case: https://secure.helpscout.net/conversation/2926565892/558092

suzoutlet avatar May 08 '25 12:05 suzoutlet