flamelink / flamelink-js-sdk

🦊 Official Flamelink JavaScript SDK for both the Firebase Realtime database and Cloud Firestore
https://flamelink.github.io/flamelink-js-sdk
MIT License
43 stars 5 forks source link

Closest image size not returned #84

Closed cyril-drouet closed 3 years ago

cyril-drouet commented 5 years ago

Getting images based on size doesn't seem to work properly. If I try to get an image like this:

this._app.storage.getURL({
  fileId: product['image'][0].id,
  size: {
    width: 70,
    height: 70,
    quality: 1
  }
})

I get the following warning: [FLAMELINK] The provided path (70_70_100) has been ignored because it did not match any of the given file's available paths. Available paths: 375_9999_100, 667_9999_100, 900_9999_100, 1080_9999_100, 1440_9999_100, 1920_9999_100

But the doc says it should give me the first available size bigger than the given size which in that case should be 375x9999

Also, this doesn't seem to work (it gives no warning but it gives the original image instead of the resized one) :

this._app.content.get({
  schemaKey: 'products',
  populate: [{
    field: 'image',
    size: {
      width: 70,
      height: 70,
      quality: 1
    }
  }]
})
jperasmus commented 5 years ago

Hi @cyril-drouet

If you are using Cloud Firestore, version 1.0.0-alpha.20 should fix the populate functionality for images with a specific size option. I have not looked into the issue to find the first available size yet.

gitdubz commented 3 years ago

Hey @cyril-drouet

If you are unsure of the image size you want to retrieve, omit adding the height property

This will return the closest image size in the populated url value. If you specify the height value, it will try to match an exact value, I will update the docs for this.

this._app.content.get({
  schemaKey: 'products',
  populate: [{
    field: 'image',
    size: {
      width: 70,
      quality: 1
    }
  }]
})