cloudinary / frontend-frameworks

Cloudinary javascript frontend frameworks SDKs, including Shared HTML layer, Angular, React and Vue SDKs
https://www.cloudinary.com
MIT License
44 stars 15 forks source link

AdvancedImage component responsiveness compromised with conflicting plugins in React (17 and 18) #207

Open RobSchilderr opened 1 year ago

RobSchilderr commented 1 year ago

New issue for cloudinary/frontend-frameworks

"@cloudinary/react": "^1.11.0",

For which package is this issue?

"@cloudinary/react": "^1.11.0",

Describe the issue in a sentence or two.

The AdvancedImage component's responsiveness is compromised when used with conflicting plugins simultaneously, which can cause excessive data download for users. A simplified implementation that only utilizes the responsive plugin resolves the issue. This issue may be a bug in the React SDK.

Issue Type (Can be multiple)

Steps to reproduce

  1. Use the AdvancedImage component with conflicting plugins such as the placeholder and lazyload plugins in a React app.
  2. Observe the compromised responsiveness of the component and the excessive data download for some users.
  3. Switch to a simplified implementation that only uses the responsive plugin to resolve the issue.

Error screenshots

N/A

Browsers (if issue relates to UI, else ignore)

Versions and Libraries (fill in the version numbers)

package SDK version

Config Files (Please paste the following files if possible)

Package.json:

Code Examples

Original implementation:

<AdvancedImage
  style={style}
  alt={alt}
  cldImg={myImage}
  plugins={[    ...(withBlur      ? [          placeholder({            mode: 'blur',          }),        ]
      : []),
    lazyload(),
    responsive({
      steps: 150,
    }),
  ]}
/>

Simplified implementation:

<AdvancedImage
  style={style}
  loading="lazy"
  alt={alt}
  cldImg={myImage}
  plugins={[
    responsive({
      steps: 150,
    }),
  ]}
/>

In the original implementation, the AdvancedImage component is used with three plugins: the placeholder plugin with a blur mode (if withBlur is true), the lazyload plugin, and the responsive plugin with 150 steps. In contrast, the simplified implementation only uses the responsive plugin with 150 steps and sets the loading attribute to "lazy". This results in a more efficient and responsive image-loading experience for users.

tamaracloudinary commented 1 year ago

Thanks for reporting this, we are checking your inquiry with the team and will update you soon with our insights.

tamaracloudinary commented 1 year ago

Hi @RobSchilderr, A new version with a fix to the order of the plugins was just released, and now the example in the docs should work as expected. Please let me know if you still experiencing issues