Problem/Motivation

I have an image field with a minimal resolution bigger than 600x600. When i use Devel Generate to create default content. The generated images resolution are smaller than the defined minimals in the field.

Steps to reproduce

1. Create a content type with a minimal resolution of 800x800 ( any resolution bigger than 600x600 works to reproduce the bug).
2. Run devel generate to create content of that content type.

Proposed resolution

The generateSampleValue method should check if the minimal resolution is bigger than 600x600, and redefine the max_resolution value accordingly.

Remaining tasks

Add tests, see #12

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

Please review the provided patch.

Comments

guiu.rocafort.ferrer created an issue. See original summary.

rootwork’s picture

Issue tags: +Novice, +Portland2022

Tagging as novice.

Task: Apply the patch (ask mentors if you need help). See if it applies.

If it does apply: See if it does what it says it does and report back with screenshots.
If it does not apply: Report any error messages you get, and change the status to "Needs work".

andregp’s picture

StatusFileSize
new1.32 KB
new767 bytes

The previous patch had some Coding Standard errors.

andregp’s picture

StatusFileSize
new169.33 KB
new183.04 KB
new122.81 KB

I was either unable to reproduce the bug or the bug doesn't exists (maybe I just didn't follow the right steps).

I created a new content type with only one field (a required image field with min resolution of 600x600), then, without the patch code, ran Devel generate to create some content from this new content type I just made. All the images had the correct size.

andregp’s picture

Status: Active » Needs work

Changing status as this issue already have a patch.

rootwork’s picture

Issue tags: -Novice

Thanks @andregp! Untagging as novice as it sounds like more investigation needs to happen.

guiu.rocafort.ferrer’s picture

Status: Needs work » Active
StatusFileSize
new209.04 KB
new101.68 KB
new111.38 KB

Hi, i will rephrase the steps to reproduce as they might not be as clear as i thought:

1. Create a content type with a minimal resolution of 800x800 ( any resolution bigger than 600x600 works to reproduce the bug).
2. Run devel generate to create content of that content type.

I attached some screenshots reproducing the bug and applying the patch.

andregp’s picture

Status: Active » Needs review

Thanks for the clarification @guiu.rocafort.ferrer!

Sending to Needs Review as we already have a patch with a possible solution and the Active status is used only when there's no patch attached (reference here).

andregp’s picture

Issue tags: +Novice

Adding back Novice tag as it's a simple review.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

roberttabigue’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new467.12 KB
new361.13 KB
new390.41 KB

Hello,

I applied Patch #3 and confirmed it works now.

Please see attached files.

Thank you.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice +Needs tests

Can we get some tests of this so there is no regression? There is an existing test \Drupal\Tests\image\Kernel\ImageItemTest that looks like it can be used. I am adding the "needs tests' tag.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Issue tags: +Bug Smash Initiative

This still needs a test.

guiu.rocafort.ferrer’s picture

StatusFileSize
new3.59 KB

This patch file also adds a new test to check both the default case, and the bug issue.

Please review it.

guiu.rocafort.ferrer’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

I am removing the needs test tag, also changing status to Needs review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Thanks for the tests. Just FYI for next time when adding tests it helps to upload a test-only patch followed by the full patch. Also an interdiff between patches.

But I ran the tests locally without the fix and it failed as expected

Failed asserting that 709 matches expected '800'.
Expected :800
Actual :709

larowlan’s picture

Crediting @rootwork for mentoring, @quietone for a review and @smustgrave for running the test locally

  • larowlan committed fc4d59e3 on 10.1.x
    Issue #3276965 by guiu.rocafort.ferrer, andregp, roberttabigue, quietone...

  • larowlan committed 4578bbd6 on 11.x
    Issue #3276965 by guiu.rocafort.ferrer, andregp, roberttabigue, quietone...
larowlan’s picture

Version: 9.5.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 4578bbd and pushed to 11.x. Thanks!

Backported to 10.1.x. Not backporting any further because 9.5.x and 10.0.x are now in security only mode.

Fixed on commit (comment was > 80 chars).

diff --git a/core/modules/image/tests/src/Kernel/ImageItemTest.php b/core/modules/image/tests/src/Kernel/ImageItemTest.php
index 037a6378300..a1879bb4428 100644
--- a/core/modules/image/tests/src/Kernel/ImageItemTest.php
+++ b/core/modules/image/tests/src/Kernel/ImageItemTest.php
@@ -155,7 +155,7 @@ public function testImageItem() {
   }
 
   /**
-   * Tests generateSampleItems() method under different min_resolution and max_resolution configurations.
+   * Tests generateSampleItems() method under different resolutions.
    */
   public function testImageItemSampleValueGeneration() {
 

Status: Fixed » Closed (fixed)

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