[source-drupal] Add ability to use image derivatives
See original GitHub issueSummary
Drupal have a nicely developed feature to generate “image styles”: derivatives of original image differing in size, crop, etc. There are many modules in Drupal ecosystem that can extend “image styles”, e.g. Focal point.
Backend requirements:
- Install Consumer Image Styles module.
- Create at least one consumer and select image styles you want to get with request.
- Add
consumerId=YOUR_CONSUMER_ID
query string parameter to your request.
Basic example
Your JSON:API response will contain links to selected derivatives:
"meta": {
"imageDerivatives": {
"links": {
"medium: {
"href": "http://example.org/sites/…/medium/…/img.png?itok=LQM1dnmK",
"meta": {
"rel": [
"drupal://jsonapi/extensions/consumer_image_styles/links/relation-types/#derivative"
]
}
},
}
}
}
Motivation
If content is managed by Drupal It would be great to use those derivatives in statically generated site. Gridsome g-image
component can resize and crop local images only, and it can’t crop image around focal point. It is just one case that Drupal backend can handle for you, there are many more.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Speed up Gatsby Builds With Drupal Image Processing
Drupal has the built in ability to generate its own derivative images on demand and cache them, so why not just build our...
Read more >How to use Drupal to optimize images on the fly - Desarol
It allows developers to take full advantage of Drupal's image styles and ImageToolkit abstraction to generate derivatives on the fly using ...
Read more >image.module - Convert theme_ functions to Twig - Drupal
Add a new image style. Go to Configuration->Image Styles, click on the 'Add image style' button, and enter an image style name (let's...
Read more >Image Derivative - Chris McCormick
One simple example is that you can take the derivative in the x-direction at pixel x1 by taking the difference between the pixel...
Read more >Libraries - @imgix/gatsby
Overview / Resources; Why use imgix instead of gatsby-transform-sharp? ... As we are able to create far more derivative images at different resolutions...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @Al-Rozhkov! Sorry for the delay, I didn’t realize I had a another ticket assigned to me 😃. Let me investigate this further to see if I have any “knowledge-gaps” on how this could all work together.
I’ll keep you updated!
Perhaps a more scalable solution would involve a new option in the
DrupalSource
, ‘fetchImageDerivatives’:(PoC)
With this new option enabled, the script would check for image derivatives inside the link attribute by looking for a item with href and the rel attribute used by the Drupal Consumer Image Styles module.
Page query: