Closed amureki closed 1 year ago
Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:
Coverage data is based on head (
63adbc1
) compared to base (266115d
). Patch coverage: 100.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@amureki I added a commit that replicates the same API from the picture template tag. I have a feeling that might be more consistent. We could also consider having those attributes passed via GET parameters, so you can have a more dynamic REST API. Thoughts?
@codingjoe yeah, that looks better. I'd be fine moving forward with it!
We could even build a React and Vue component for the package, or at least an example, right?
@amureki I pushed an updates, that includes your suggestions. I am curious what you think.
@amureki I pushed an updates, that includes your suggestions. I am curious what you think.
Yeah, that's good and interesting idea with the GET
params. I wonder if we should prefix those somehow to not clash with other possible API params that other dev could define in their APIs...
@amureki I pushed an updates, that includes your suggestions. I am curious what you think.
Yeah, that's good and interesting idea with the
GET
params. I wonder if we should prefix those somehow to not clash with other possible API params that other dev could define in their APIs...
Good idea, we should at least add the field name a prefix in case there are multiple picture fields. Do you think it'll be sufficient.
@chgad, we are proposing some changes to the DRF field. Since you suggested the original implementation. How do you feel about this?
cc @SebastianKapunkt what do you think?
It helps to reduce the payload of the request. To get the actual source you want to use in the frontend, you still need a JS snipped to extract what you need.
Maybe it makes sense to even add more parameters to the request, to the point where you only get one URL back.
Maybe it makes sense to even add more parameters to the request, to the point where you only get one URL back.
@SebastianKapunkt why would you want only one URL? You mean, if you already know all device information like pixel density and the final size? Pixel density is known per device, but even apps can be resized (e.g. via screen rotation). So, you'd never know the actual size.
To get the actual source you want to use in the frontend, you still need a JS snipped to extract what you need.
We wanted to keep the API payload as atomic as possible. Having a single srcset
-string would be helpful in HTML only. That being said, a simple Array.join(', ')
should be feasible for most.
@amureki maybe we should consider adding examples for React and Vue components to the docs?
@amureki maybe we should consider adding examples for React and Vue components to the docs?
You may provide optional GET parameters to the serializer, to specify the aspect ratio and breakpoints you want to include in the response. The parameters are prefixed with the
fieldname_
to avoid conflicts with other fields.Note that the
media
keys are only included, if you have specified breakpoints.