Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ImageTransformStrategy for improved control over image transformations #3240

Merged
merged 5 commits into from
Nov 27, 2024

Conversation

michaelbromley
Copy link
Member

Description

This relates to #3040, and solves the issue by introducing a new ImageTransformStrategy which can be used to control what kinds of transforms are permitted when requesting an image from the AssetServerPlugin.

It also features a strategy to limit transforms to presets only:

import { VendureConfig } from '@vendure/core';
import { AssetServerPlugin, PresetOnlyStrategy } from '@vendure/asset-server-plugin';

export const config: VendureConfig = {
  // ...
  plugins: [
    AssetServerPlugin.init({
      // ...
      imageTransformStrategy: new PresetOnlyStrategy({
        defaultPreset: 'large',
        permittedQuality: [0, 50, 75, 85, 95],
        permittedFormats: ['jpg', 'webp', 'avif'],
        allowFocalPoint: false,
      }),
    }),
  ]
};

Breaking changes

No

Relates to #3040. This new strategy allows you to control the
parameters that get used to transform the image. We also expose a new PresetOnlyStrategy that
limits transforms to just the presets.
Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Nov 27, 2024 9:44am

In response to a code scanning alert. Looks like it is a false
positive.
Copy link

sonarqubecloud bot commented Nov 27, 2024

Quality Gate Passed Quality Gate passed

Issues
24 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@michaelbromley michaelbromley merged commit dde738d into minor Nov 27, 2024
32 checks passed
@michaelbromley michaelbromley deleted the issue-3040 branch November 27, 2024 10:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant