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

Error in a script when activating the WebP Add-on (Avada theme)

Open mifrero opened this issue 1 year ago • 0 comments

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version Yes, the version is 3.15.7
  • Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug When the WebP add-on is activated and images are added inside JS scripts this error is generated: https://i.imgur.com/vjpUI65.png The error occurs because we are replacing single quotes with double quotes in the image directory reference.

To Reproduce Steps to reproduce the behavior:

  1. Enable WebP Add-on
  2. Go to homepage
  3. Check the 2 testimonial sliders (doesn't show)
  4. See error on browser console

Expected behavior Enabling WebP Add-on doesn't generate any error

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Theme: Avada Image optimizer: Optimus Ticket: https://secure.helpscout.net/conversation/2475162420/467998?folderId=2952229 Suggested solution: I've solved it in customer website escaping the single quotes with a backslash in this line of code so the line now looks like this: $new_attr = preg_replace( '@' . $attribute['name'] . '\s*=\s*["\'][^"\']+["\']@s', $attribute['name'] . '=\'' . $new_value . '\'', $attribute[0] ); $html = str_replace( $attribute[0], $new_attr, $html );

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

mifrero avatar Jan 11 '24 17:01 mifrero