Skip to content

ImageKit aspectRatio param double encoding #195

Open

Description

@maybephilipp

ImageKit operation for aspectRatio (ar) url-encodes value twice.

Input:

{
  imagekit: {
    ar: '9-16'
  }
}

Output: https://ik.imagekit.io/image.png?updatedAt=1778956861259&tr=ar-9%252D16%2Cfo-custom%2Cw-640%2Cc-maintain_ratio

You can see ar-9%252D16 which is:

decodeURIComponent(decodeURIComponent('ar-9%252D16')) === 'ar-9-16'  // true
decodeURIComponent('ar-9%252D16') !== 'ar-9-16'  // false – 'ar-9%2D16'

This breaks ImageKit's aspect ratio functionality.

P.S. Yes, correct syntax for aspect ratio in ImageKit is dashed, not semicolon.

Activity

  1. maybephilipp commented on May 19, 2026

    @maybephilipp
    Author

    I tried to overcome this bug using transformer, but in @unpic/svelte this param (custom transformer) is completely ignored (https://github.com/ascorbic/unpic-img/blob/0128fb084010f30808ec334a1637bb47638ad517/packages/core/src/auto.ts#L64-L90 , https://github.com/ascorbic/unpic-img/blob/0128fb084010f30808ec334a1637bb47638ad517/packages/svelte/src/lib/source.svelte#L9).

    I guess, the best way is to write my own Svelte support.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions