Skip to content

[Feature] Important - Update width logic #171

Closed

Description

@colbyfayock

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.

Activity

  1. added
    enhancement
    on Dec 7, 2023
  2. Baroshem commented on Dec 8, 2023

    @Baroshem
    Collaborator

    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 :)

  3. linked a pull request that will close this issueChore/2.5.0 #173on Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions