NavneetKaur0111
NavneetKaur0111

Reputation: 147

How to get urls for every image format in strapi?

I have a project deployed to heroku, and when both the local branch and the heroku have the same code, they still are returning different types of data for the image formats. The differences are explained below:

The local branch has the following format of data, where every format has a url that can be used to access the image.

enter image description here

The staging environment is giving the following type of data under every image format, which doesn't include any url, which is not required and there is no way to access the image of any particular format through this.

enter image description here

Upvotes: 1

Views: 1314

Answers (2)

Hadi Majidi
Hadi Majidi

Reputation: 431

The question is old, but maybe is usefull for someone. You should ask the url during your request from server. Here is example

const apiAddrss = "/api/your-api-address?locale=your-languge-if-applicable&filters[title-or-slug][$eq]=if-you-want-use-title-or-slug&populate=*,your-requested-component-if-your-requested-page-include-component,other-component,component-that-includes-photo.name-of-sub-component-if-applicable&populate=maincomponent-that-has-photo.sub-component-that-has-photo.name-of-phot-component"

Upvotes: 0

Sjouke
Sjouke

Reputation: 329

If you have set the (Settings > Media Library >) Responsive friendly upload to true before uploading the image it will create the formats for you. The formats (and the settings for it) are stored in the database. Try cloning the database from one environment to the other together with the local uploads folder (probably you want something like S3 to store the images for you).

Upvotes: 2

Related Questions