0

I'm using below modules for image crop

https://www.drupal.org/project/image_widget_crop
https://www.drupal.org/project/cloudinary
https://www.drupal.org/project/consumers
https://www.drupal.org/project/consumer_image_styles
https://www.drupal.org/project/jsonapi

Returning data in JSON API.

Using multiple paragraphs for images. I have 1 image as logo & 1 image as content.

For 1 image it's showing correct image width & height, X & Y co-ordinates (derivatives).

But for multiple image it copy same height, width, x, y co-ordinates to other images.

So it's not showing image wise derivatives for multiple images.

Once image is uploaded it saved to cloudinary.

{
"meta": {
"derivatives": {
"box": "http://res.cloudinary.com/XXX/image/upload/s--CJHoE3mM--/c_crop,h_400,w_400,x_29,y_46/test.jpg?itok=4GARJEFS",
"thumbnail": "http://res.cloudinary.com/XXX/image/upload/s--vlxu-1hL--/c_fit,h_100,w_100/test.jpg?itok=hed-1-Mh",
"wide": "http://res.cloudinary.com/XXX/image/upload/s--4-Vk3FhO--/c_crop,h_200,w_356,x_76,y_86/test.jpg?itok=GOzme5ht"
}
}

Does anyone faced this issue?

0

You can try the code

use Drupal\image\Entity\ImageStyle;
use Drupal\file\Entity\File;


$filed_images = $paragraphs->get('field_image')->getValue();
 $images =[];
 foreach ($filed_images as $image) {
            $images[] = ImageStyle::load('273x273')
              ->buildUrl(File::load($image['target_id'])
                ->getFileUri());
          }
  • It's loading image style for another image as well. But it's same value – Julia Aug 22 '18 at 11:52

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.