Problem

I get an error while comparing two revisions when images changed, image thumbnail of the image field should be showed and no preview image style is set.

Notice: Undefined index: preview_image_style in Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build() (line 83 of sites/default/modules/contrib/diff/src/Plugin/diff/Field/ImageFieldBuilder.php).

Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build(Object) (Line: 94)
Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 96)
Drupal\diff\DiffEntityComparison->compareRevisions(Object, Object) (Line: 118)
Drupal\diff\Plugin\diff\Layout\UnifiedFieldsDiffLayout->build(Object, Object, Object) (Line: 167)
Drupal\diff\Controller\PluginRevisionController->compareEntityRevisions(Object, Object, Object, 'unified_fields') (Line: 49)
Drupal\diff\Controller\NodeRevisionController->compareNodeRevisions(Object, '82899', '83284', 'unified_fields')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

ImageFieldBuilder is looking for the preview image style, but it is not defined.

Proposed resolution

Diff should skip the thumbnail if no preview image style is given.

Workaround

Uncheck "Show image thumbnail"

or better

set preview image style for image.

Issue fork diff-2905565

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pminf created an issue. See original summary.

pminf’s picture

Status: Active » Needs review
StatusFileSize
new1009 bytes

Here is a patch which fixes the undefined index error. But I'm still wondering how to set the preview image style for image fields. No problem with Drupal 7, but in Drupal 8 the setting seems to be moved elsewhere (not admin/structure/types/manage/%nodetype%/fields/node.%nodetype%.%field%). Any idea?

Status: Needs review » Needs work

The last submitted patch, 2: undefined-index-preview-style-2905565-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

snehi’s picture

Assigned: Unassigned » snehi
Status: Needs work » Needs review
StatusFileSize
new516 bytes

Applied the above patch but no thumbnail image is showing now, error is removed but without thumbnail image.

Added a new patch for the diff module. Please review.

johnchque’s picture

Status: Needs review » Needs work

@snehi are you removing a working functionality? Please let's create a test only patch first so we can identify the problem. :)

pminf’s picture

@snehi: If you set preview image style for the image to check it should be visible in the diff view. My patch just fixes the error if no preview image style is set.

sahil432’s picture

@pminf your patch will remove all thumbnail images and when I applied @snehi patch it removes error warning but one issue is still open i.e sequence of images are not right reason behind that is revision node last image comes as thumbnail array in latest node so it breaks sequence.

silvi.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new943 bytes

Added patch will resolve both undefined index error and sequence of image issue.