Error when trying to set up Contextual Crop Reference with ImageWidgetCrop Adapter

Created on 20 January 2024, 10 months ago
Updated 24 January 2024, 10 months ago

Problem/Motivation

I am trying to setup an image media field with Contextual Crop. I followed the instructions here β†’ :

  1. Activated "Activate Media Contextual Crop Reference"
  2. Enabled "media_contextual_crop_iwc_adapter"
  3. Added a "Reference / media with contextual modifications" image field.

When I then edit a node, add an image media and click the pencil at the added item, I get no crop widget nor anything else (see attached screenshot). Also if I try to save the node I get "The website encountered an unexpected error. Try again later." in the browser and the following error in the PHP log:

Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "'context' not found" at <PROJECT_PATH>/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 817

I am using:

  • Drupal 10.2.2
  • Media Contextual Crop Reference 2.0.1
  • Media Contextual Cropping API 2.0.2
  • Media Contextual Cropping with image_widget_crop Plugin 2.0.0
  • ImageWidgetCrop 8.x-2.4

Maybe I am missing something? Thanks for any hint.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany jox

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

Comments & Activities

  • Issue created by @jox
  • πŸ‡«πŸ‡·France DrDam

    MΓ©dia Contextual Crop API came with a patch on Crop module. This patch add an data-field in the crop entity.

    Can you check if the patch correctly applied composer reinstall drupal/crop

    Did you have run an drush updb after install crop with composer ?

  • πŸ‡©πŸ‡ͺGermany jox

    Thanks for the quick reply!

    Which patch do you mean exactly, do you have a link? I saw some patch requirement before. I was wondering about it and concluded that it was already merged. Did you just update the project description and take out that patch info?

    I certainly did drush updatedb and drush cache:rebuild after install.

    I now did composer reinstall drupal/crop as you told with another drush updatedb, but the problem remains...

  • πŸ‡«πŸ‡·France DrDam

    In the media_contextual_crop (2.x) have a patch in the composer.json :

                "drupal/crop": {
                    "provide_contextual_capability_to_crops": "https://www.drupal.org/files/issues/2023-11-06/%232617818-31-provide_contextual_capability_to_crops.patch"
                }

    It theorie, composer patch will apply it automaticly

    If you run a composer reinstall drupal/crop you may this response in the console

      - Installing drupal/crop (2.3.0): Extracting archive
      - Applying patches for drupal/crop
        https://www.drupal.org/files/issues/2023-11-06/%232617818-31-provide_contextual_capability_to_crops.patch (provide_contextual_capability_to_crops)

    After the path applied, you may have to run a drush updb in order to apply the crop_update_8006 "Add context field to Crop entity"

  • Assigned to DrDam
  • πŸ‡©πŸ‡ͺGermany jox

    All right. The patch is not getting applied automatically in my setup. I did it manually and crop_update_8006 is applied now after updb!

    The error is gone, but unfortunately I still have no cropping abilities...

  • πŸ‡«πŸ‡·France DrDam

    Are you sure using a "media with contextual modification" instead of the native "reference" field ?

    In term of configuration :

    0. Define a CROP and an image style using this crop

    1. In the CONTENT TYPE,
    - On field configuration : be sure using a "media with contextual modifications" field type, instead of the "native entity reference" field type ?
    - On view mode : choose the "render" formater and a view mode for the media

    2. In the MEDIA Image STRUCTURE, you need to set :
    - in the form mode : use Image widget Crop
    - in the media view mode (the one used by the content type) : use the formater "Context crop image" on the field_image, and select a image_style who use a crop

  • πŸ‡©πŸ‡ͺGermany jox

    Thanks for the help! I followed your steps and I am getting closer, but still got issues. I now have the crop widget in the node edit form and can select a crop area, but:
    - It does not save my crop configuration. I.e. it forgets it. The next time I open the modal crop area is back to full image.
    - In the image modal there is a warning "This crop definition affects more usages of this image".
    - I cannot see any preview for my crop selection.

  • πŸ‡«πŸ‡·France DrDam

    If you have difficulty applying the patches, this is probably due to the fact that the patch on media_library_media_modify has not been applied either

    This patch is provided by the composer.json of Media Contextual Crop Reference

    "patches": {
                "drupal/media_library_media_modify": {
                    "#3270150 Add alteration": "https://www.drupal.org/files/issues/2022-06-08/manage_crops_3270150-7.patch"
                }
            }
    
  • πŸ‡©πŸ‡ͺGermany jox

    You are right. My composer-patches wasn't configured properly. I fixed that and now all patches are applied. It did even reinstall core to also apply "Issue #3263397-10: Simplify form logic in media library".

    Now one thing is fixed: It saves my crop configuration!

    But I still got these issues left:

    • In the image modal there is a warning "This crop definition affects more usages of this image".
    • I cannot see any preview for my crop selection.

    Is this what I have to expect? Thanks!

  • πŸ‡«πŸ‡·France DrDam

    In the image modal there is a warning "This crop definition affects more usages of this image".

    For the first point, I have push an update on media_contextual_crop_iwc_adapter to alter messages.

    I cannot see any preview for my crop selection.

    This "bug" aren't in my hands, if you use a croped media with a classique media_reference field, you will have the same result.
    Please ask to Image_widget_crop module mainteners

  • Status changed to Fixed 10 months ago
Production build 0.71.5 2024