nuxt-modules / cloudinary

Cloudinary Module for Nuxt
https://cloudinary.nuxtjs.org
MIT License
249 stars 34 forks source link

[Feature] Important - Update width logic #171

Closed colbyfayock closed 9 months ago

colbyfayock commented 10 months ago

Feature Request

The URL Loader was previously not applying a widthResize parameter if the widthResize parameter was larger than the width. this was to avoid creating useless URLs that didn't actually change beyond the URL.

this problem is that this logic shouldn't make that assumption in the URL Loader and should be on the caller to make that decision

This update was in v3.17.0

Upon updating, please update the width and width resize logic to correlate with the following:

  let widthResize;

  if ( typeof loaderOptions?.width === 'number' && typeof options.width === 'number' && loaderOptions.width !== options.width ) {
    widthResize = loaderOptions.width;
  } else if ( typeof loaderOptions?.width === 'number' && typeof options?.width !== 'number' ) {
    widthResize = loaderOptions.width;
    options.width = widthResize;
  }

  if ( options.width && widthResize && widthResize < options.width ) {
    options.widthResize = loaderOptions.width;
  }

This will essentially do the same thing, but now this logic is inside of the component to make that decision, along with anyone else who chooses to use the URL Loader library.

Source in Next Cloudinary with more comments for context: https://github.com/colbyfayock/next-cloudinary/blob/main/next-cloudinary/src/loaders/cloudinary-loader.ts#L35-L56

Future

The goal is to create a more reliable and simplified URL structure which may include more changes in the future, but for now, this will help avoid those assumptions being made for the caller without the ability to change how that works.

Baroshem commented 10 months ago

Hey Colby,

Thanks for reporting this. I will take a look at it in the next days due to the reasons I mentioned in DM :)