0

Hi I am using Image Widget Crop so that users can crop images according to predefined image styles. All would have worked fine without any issues had I been using Drupal in the conventional 'monolithic' way. But I am not. Instead, I have a headless Drupal setup.

That means that I do not have a Drupal theme to render my content. The problem created because of that is that apparently (from what I've read online), the actual styled images created using Image Widget Crop/Crop API are actually created when they are called/loaded in a theme. Now the theme can be backend as well. Below is what I think this happens chronologically.

  1. Create and save a post with an image cropped using Image Widget Crop.
  2. Cropped/styled image does not get created in the file system.
  3. Fetch the data using JSON API/Custom API Module
  4. Returns with empty image field because cropped/styled image is not yet created.
  5. Click on Edit post
  6. Cropped/styled image created. Because the preview of the cropped image is called by the edit form/backend theme.
  7. Fetch the data using JSON API/Custom API Module.
  8. All works fine.

What I want to do is execute some kind of hook which creates the styled/cropped image when a post is saved(step 1). That way when I fetch the data using JSON API, it is readily available.

1

The solution is using Image Style Warmer

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.