Create an Image field for Unsplash Media items

Created on 8 March 2024, 4 months ago
Updated 29 March 2024, 3 months ago

Problem/Motivation

The current setup works fine for normal image processing. However, there is no way to apply Form Mode widgets to the image. We utilize the Focal Point module heavily, along with 85K+ other sites. I think it would help the modules viability to provide an image field that can be acted upon in the form mode of the media item.

Proposed resolution

The proposed patch adds an image field, and then sets that field equal to the file ID that is used for the thumbnail metadata. The field is set to hidden on the form and display mode by default, so it won't affect current users experiences. It will, however, allow for more advanced sites to use the before-mentioned form mode widgets like they normally would with other image fields.

Also, while working through this, I noticed the config currently lies in the config/install directory. This will cause errors if you try to uninstall and re-install the module, so I've moved it to the config/optional directory.

Remaining tasks

I'm currently setting the value in a hook_presave. I do believe there is a way to probably set the value when the media item is created, but I haven't yet figured it out. So possibly update the code. Also, I should add documentation to the readme on the extra field since its hidden and may not be immediately obvious.

User interface changes

No changes by default. But an added "Image" field on the manage form display, and manage display tabs.

Data model changes

Added a new field_media_unsplash_image field.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States swilmes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024