Problem/Motivation

When some formatter configuration for the thumbnail formatter is exported and the associated image style isn't there, it blows up.

Proposed resolution

To help prevent this, we should make sure the image style is added as a dependency to the formatter configuration.

Remaining tasks

Create a patch that overrides ::calculateDependencies for VideoEmbedThumbnailFormatter.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#32 2676938-thumbnail-dependencies-32.patch10.37 KBSam152
#32 interdiff.txt5.09 KBSam152
#23 2676938-thumbnail-dependencies-23.patch8.93 KBSam152
#23 interdiff.txt1.65 KBSam152
#20 2676938-thumbnail-dependencies-20.patch8.93 KBSam152
#20 interdiff.txt695 bytesSam152
#12 interdiff.txt6.56 KBSam152
#12 2676938-thumbnail-dependencies-12.patch8.84 KBSam152
#4 2676938-thumbnail-dependencies-4.patch6.51 KBSam152
#4 interdiff.txt3.02 KBSam152
#2 2676938-thumbnail-dependencies-2.patch3.49 KBSam152
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sam152 created an issue. See original summary.

Sam152’s picture

Initial patch based entirely on the core ImageFormatter. Need to look into how this can be tested.

Also need to deal with the colorbox formatter which also has an image style.

Status: Needs review » Needs work

The last submitted patch, 2: 2676938-thumbnail-dependencies-2.patch, failed testing.

Sam152’s picture

Status: Needs review » Needs work

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

The last submitted patch, 4: 2676938-thumbnail-dependencies-4.patch, failed testing.

Sam152’s picture

Added test assertions for when the image style is deleted and added support in the colorbox formatter for onDependencyRemoval and calculateDependencies.

Still 1 failing colorbox test.

Status: Needs review » Needs work

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

The last submitted patch, 12: 2676938-thumbnail-dependencies-12.patch, failed testing.

Sam152’s picture

benjy’s picture

Status: Needs review » Needs work
  1. +++ b/src/Plugin/Field/FieldFormatter/Thumbnail.php
    @@ -36,6 +38,13 @@ class Thumbnail extends FormatterBase implements ContainerFactoryPluginInterface
    +  protected $image_style_storage;
    
    @@ -126,9 +135,10 @@ class Thumbnail extends FormatterBase implements ContainerFactoryPluginInterface
    +    $this->imageStyleStorage = $image_style_storage;
    

    Assigned to the wrong variable name.

  2. +++ b/src/Tests/FormatterDependenciesTest.php
    @@ -0,0 +1,109 @@
    +class FormatterDependenciesTest extends WebTestBase {
    

    I'd have thought you'd have gotten away with KTB just for testing the dependencies?

benjy’s picture

Status: Needs work » Needs review

Cross posted with the bot.

Sam152’s picture

Sam152’s picture

I might try a KTB version if I get time and see if it's easy enough to convert. This really isn't using a browser, but it is using some methods off WebTestBase.

Status: Needs review » Needs work

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

The last submitted patch, 23: 2676938-thumbnail-dependencies-23.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 32: 2676938-thumbnail-dependencies-32.patch, failed testing.

Sam152’s picture

Status: Needs work » Needs review
Sam152’s picture

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good apart from there is no upgrade path. Should be as simple as re-saving the form that selects the image and then re-exporting the config.

Sam152’s picture

Yeah, I think it's fine for this to be an additional benefit for new installations and installations that decide to resave their formatters.

Thanks for the review.

  • Sam152 committed aa95d3a on 8.x-1.x
    Issue #2676938 by Sam152, benjy: Ensure VideoEmbedThumbnailFormatter has...
Sam152’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.