Support Crop API

Created on 23 June 2021, almost 4 years ago
Updated 23 March 2023, about 2 years ago

Problem/Motivation

I am using entity share module with Media entity and crop API.
Adding crops to media image attached to node in source are not created on client site.

Steps to reproduce

  1. Add crops to media image
  2. Attach media created in step 1 to any node.
  3. Try to import node created in step 2 from any client site.
  4. Node and media will imported successfully on client but not the crops in media image.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India bunty badgujar Delhi

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France Grimreaper France 🇫🇷
  • Issue was unassigned.
  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    I finally got time to give a look at this issue.

    I confirm this is not a problem related to Entity Share but the Crop API module:

    JSON API integration Active

    So solution will both work for Focal Point and Manual crop or any kind of crop.

    As crop type is a config entity, it should be the same between your client and server website.

    As you mentioned the problem is that there is no proper relationship between a crop content entity and the image file entity it is applied on.

    And there is also that in the attributes of this content entity, there is "entity_id":1, which is an ID and not an UUID.

    I think what could be done as a workaround to automatically import the crop:
    1. in the image field output add information of the (or the multiples) crop content entity JSON:API URLs. How?
    - With a normalizer like you proposed?
    - or maybe like in comment #2890651-14: JSON API integration

    I think the place for this is in the Crop API module.

    2. add an event subscriber on RelationshipFieldValueEvent or an import plugin processor that will read this or these URLs to import automatically the crop content entity.

    But the crop content entity would need to be prepared:
    3. create a field enhancer to transform the "entity_id" attributes into a UUID and the opposite in doTransform().

    This field enhancer could reside either in Entity Share or in the Crop API module. Maybe better in Crop API.

    4. should the uri attributes on crop content entity be ignored or will require special treatment too? will the physical file be regenerated automatically?

    I will also ping in the other issue to ask for feedbacks.

  • 🇺🇸United States pbabin

    We're looking at needing something like this as well. Has anyone been able to successfully do this and can share their code? We're just using crop api with image widget crop. I see in the database all the points that @maxpah and @grimreaper are making so I think we should be able to pass the crop information along; however, I am at a loss of where to start. It doesn't look like there is any traction on the crop api side. So is it advisable to add these modifications into our own module and try the import?

    Any guidance to point me in the right direction is greatly appreciated. Entity share is such an amazing tool and our organization is extremely grateful for all that it does!

    Thank you in advance.

  • Hello @pbabin,
    In one of our project we faced similar problem.
    The solution was implemented using custom module to bind another extra field which stores the crop positions data.
    Once the data is synced we wrote code to use those field value and apply crop to image.

  • 🇺🇸United States pbabin

    Thank you @grimreaper for linking this issue to JSON API integration Active !

    I've applied the MR !9 patch from #2890651 and the crops are being brought over with Entity Share! Please note that my setup included a locked policy. With the policy turned on, the crops did not come over. I've converted the policy to create only and the crops come over and are applied correctly.

    So much gratitude for this package! Thank you.

  • 🇫🇷France prudloff Lille

    I tried the patch from JSON API integration Active and it correctly adds a crop computed field on file API responses.
    But it does not seem to be enough. I get this notice and the crop is not imported:

    [notice] Error during import. The field crop does not exist.

    I suppose entity_share does not know what to do with a computed field?
    I guess an enhancer could handle this.

    Also the "changed" property of files is not updated when the crop changes, so entity_share_cron will not try to reimport the file when its crop has changed.

  • 🇧🇪Belgium blacksnipe

    Hi

    I've applied the MR for JSON API integration Active via composer.
    After some debugging, the data for focal point and cropping came through.

    The patch needs to be applied to both server and client(s) for it to work.
    Tested and approved for our case.

    Thanks for the contribution everyone!

Production build 0.71.5 2024