I've just noticed a small problem, while I was working on a custom module in one of our current projects. I've created a node type inlcuding an image field and included the configuration export in a custom module. Originally I wasn't using Colorbox and used the default image display with the "medium" image style. In the config dependencies, "image.style.medium" was correctly added.
Now, I've decided to use Colorbox as field formatter instead. setting the "medium" image style as "colorbox_node_style". When I now export the changed node view display again, the config dependency on the image style is missing.
It may sound like a rather small issue, but there may be certain situations, where this missing line can cause troubles. Imagine, you're providing a custom module and package all needed aspects like node type, fields, display settings, as well as the used image styles itself into this module. If the config dependency is missing, Drupal may install the configuration entities in the wrong order, leading to errors.
In our case, the image style already exists anyway, so I can't provide a specific situation to trigger an error. But I did have problems in similar situations, where I didn't update the module's dependencies accordingly to the included configuration entities, leading to a wrong installation order of my modules, ending up in errors
Comment | File | Size | Author |
---|---|---|---|
#3 | 2686805_colorbox_image_style_dependency.patch | 3.81 KB | frjo |
|
Comments
Comment #2
frjo CreditAttribution: frjo commentedThis sounds definitely like a bug. Will take a look at it and get it fixed.
Comment #3
frjo CreditAttribution: frjo commentedPlease try out this patch. You will need to resave your content type display settings and then export the configurations.
It should add all the image styles that the Colorbox formatter uses as dependencies.
The code are adjusted functions from the core ImageFormatter that has been added quite recently I believe.
Comment #4
agoradesign CreditAttribution: agoradesign commentedThanks, works for me! :-)
Comment #5
agoradesign CreditAttribution: agoradesign commentedSorry, I have to set it back to "needs work". It works basically and is a good progress in comparison to the original state, but I've found out, that, if you have two image fields on the same node, both using Colorbox, but different image styles, only one style gets added.
Here's an example:
-> image.style.news is missing...
Comment #6
frjo CreditAttribution: frjo commentedThanks for testing this! I assume it works when one has two image field with different image styles?
Comment #7
agoradesign CreditAttribution: agoradesign commentedYou mean, with default image formatter? hmm good question. Haven't really tested this so far...
I did a quick look at my code repo, but unfortunately I've added the second image field together with Colorbox display, and I can't do some real testing at the moment
Comment #8
agoradesign CreditAttribution: agoradesign commentedJust came across this issue. I still haven't found time to test the behaviour of default image formatter. However, the patch from #3 is definitely an improvement. We use it in every project. Also, the described setup in #5 is definitely not the frequently used one.
So I plead for committing the patch, and keep the issue open for further improvements (or open a separate one).
btw, what's your plan for releasing 1.1? Since 1.0 some time has passed already, and a number of commits are in already. I saw in #2626466-16: Notice: Undefined index: theme_hook_original in twig_render_template() that people already start to create patches of already committed code to avoid using the dev version.
Comment #10
frjo CreditAttribution: frjo commentedCommitted to 8-dev.