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
42 stars 5 forks source link

can populate media field get multiple image sizes? #40

Closed jordanch closed 5 years ago

jordanch commented 5 years ago

populating content with relational media data returns a single url for a single image size, could relational populate for media fields work similarly to storage.getURL() doc where an option size: 'device' returns a device-size-relative image or have an object map of sizes to URLs?

Thanks

jperasmus commented 5 years ago

Hi, I can take a look. It uses the storage.getURL() method internally, so might be as easy as making sure the size option is passed through to that method. Will let you know.

jperasmus commented 5 years ago

https://github.com/flamelink/flamelink-js-sdk/pull/42 should hopefully take care of this. It will be available in the next alpha release.

gabber235 commented 5 years ago

First of all, is this already in the 1.0.0-alpha.11 version. If so, how would I enable the sized URLs to appear in a get request?

jperasmus commented 5 years ago

A single sized URL is available in the latest alpha release, but not multiple sizes.

To specify a specific size for the URL to retrieve you can use the following populate syntax:

app.content.get({
  schemaKey: 'someSchema',
  populate: [
    {
      field: 'someImage',
      size: {
        width: 1024,
        height: 9999,
        quality: 0.75
      }
    }
  ]
});
ngmiduc commented 5 years ago

Does this also work with a specific EntryID ?

const response = await app.content.get({
          schemaKey: "content",
          entryId: id,
          populate: [
            {
              field: "images",
              size: {
                width: 375,
                height: 9999,
                quality: 1
              }
            }
          ]
        })
jperasmus commented 5 years ago

This should work with an entryId as well.

ngmiduc commented 5 years ago

Hi, sorry again. Somehow I can not manage to populate the right size. Populating works but not with the size. I don't know if I have something wrong or not ... (I did not change anything in the flamelink settings for the sizes)

  try {
        const response = await app.content.get({
          schemaKey: "article",
          entryId: id,
          populate: [
            {
              field: "banner",
              size: {
                width: 1080,
                height: 9999,
                quality: 1
              }
            },
            {
              field: "images",
              size: {
                width: 375,
                height: 9999,
                quality: 1
              }
            }
          ]
        })

        console.log(response)

...

It returns the right Object of the given ID but the images urls are not sized accordingly to the given sizes. The "banner" and "images" are media fields in flamelink. I have tried only using one field, adding path to the size object and also setting quality to 1 or 1.0.

I am using:

    "firebase": "^6.2.0",
    "flamelink": "^1.0.0-alpha.19",
jperasmus commented 5 years ago

Can you try with quality: 100?

ngmiduc commented 5 years ago

Hi, it still returns me the wrong image size.

jperasmus commented 5 years ago

You were right the quality should be 1 and not 100. Can you test again with 1.0.0-alpha.20?

ngmiduc commented 5 years ago

HI, thanks for the answer. After updating to 1.0.0-alpha.21 it works now.

jperasmus commented 5 years ago

Awesome, thanks for confirming.

rubenheymans commented 4 years ago

I'm on alpha.28 and the resizing is not working for me, only the first one works, all others return the original image size