spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
104 stars 29 forks source link

src values should be saved as string instead of an array in content files #172

Closed ncla closed 2 years ago

ncla commented 2 years ago

Bug description

Issue extracted from here: https://github.com/spatie/statamic-responsive-images/pull/149#issuecomment-1205745805

src values are saved as an array when there is no possible way for src to have multiple values with this addon.

While not exactly a show stopper, I think this inconsistency should be addressed.

How to reproduce

Simply save a responsive field with an asset.

Logs

No response

Environment

-

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

No response

ncla commented 2 years ago

The culprit seems to be with preProcess method in Assets fieldtype. While the core Assets fieldtype process method handles max_files being 1, the preProcess method does not and creates an array.

https://github.com/spatie/statamic-responsive-images/blob/main/src/Fieldtypes/ResponsiveFieldtype.php#L140