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

fix(cloudinary): fit types, auto format & quality #76

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

mayashavin
Copy link
Contributor

Add the following:

  1. More types for resizing "fit"
  2. Add default format and quality
  3. Remove extension for Cloudinary images since they are not needed.
  4. Fix unit tests.

@codecov-io
Copy link

Codecov Report

Merging #76 (5f505b1) into master (a12ea9b) will decrease coverage by 23.58%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #76       +/-   ##
===========================================
- Coverage   73.22%   49.64%   -23.59%     
===========================================
  Files          21        4       -17     
  Lines         549      139      -410     
  Branches      130       34       -96     
===========================================
- Hits          402       69      -333     
+ Misses        145       70       -75     
+ Partials        2        0        -2     
Impacted Files Coverage Δ
src/runtime/utils.ts 2.85% <0.00%> (-94.29%) ⬇️
src/utils.ts 44.44% <0.00%> (-50.00%) ⬇️
src/index.ts 67.50% <0.00%> (-27.50%) ⬇️
src/runtime/image.ts
src/providers/fastly/runtime.ts
test/fixture/base/providers/random/index.ts
src/providers/twicpics/index.ts
src/providers/cloudinary/index.ts
src/providers/imgix/runtime.ts
src/providers/twicpics/runtime.ts
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a12ea9b...5f505b1. Read the comment docs.

export default <RuntimeProvider> {
getImage (src: string, modifiers: ImageModifiers, options: any) {
const operations = operationsGenerator(modifiers)
const mergeModifiers = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be modifiers = { ...defaultModofiers, ...modifiers } 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to do it. Actually I tried it before, the problem is in image.ts, format is passed with undefined value

if (!size.format) {
  size.format = operations.format
}

And here :

const { url } = image(src, {
  ...operations,
  width: size.width,
  format: size.format
})

so it always overwrite the default value with undefined if there is none passed. Either we fix the code logic here, or we check per provider :). WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think defaults should be null then we can use defu here /cc @farnabaz

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are refactoring components, This can be fixed in the refactor process

@farnabaz
Copy link
Member

Thank you @mayashavin ❤️

@farnabaz farnabaz changed the title Add: fit types, auto format & quality for Cloudinary fix(cloudinary): fit types, auto format & quality Nov 13, 2020
@farnabaz farnabaz merged commit 74ef445 into nuxt:master Nov 13, 2020
procrates pushed a commit to procrates/nuxt-image that referenced this pull request Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants