Skip to content

Conversation

@marbru
Copy link
Contributor

@marbru marbru commented Oct 17, 2025

When triaging this issue we realized that the UI for customizing image dimensions is confusing, and it's applying unexpected defaults silently (eg, overriding user height to keep aspect ratio).

This PR does not fix the bug, but makes the UI a bit clearer:

  • there is now a size/dimensions tab, where all settings relative to size are set (width, height and cropping)
  • "autoscaling" and "use original image" options were legacy and not used in the code, so have been removed
  • help text now provides more clarity over what will happen

Before, the UI looked like this:

Screenshot from 2025-10-17 10-25-34 Screenshot from 2025-10-17 10-25-25

And now it looks like this:

Screenshot from 2025-10-17 12-44-37

Issues / notes

  • I have tested this manually in a local instance, and added some plugin-level tests
  • I have not tested that the thumbnail options keep working the same
  • Will translations be affected? Do we need to provide new translated text?

Summary by Sourcery

Improve the image plugin UI by consolidating dimension controls into a clearer Dimensions tab, removing unused legacy options, and updating help text for better user guidance

Enhancements:

  • Group all image size settings under a new ‘Dimensions’ tab in the plugin UI
  • Remove legacy ‘automatic scaling’ and ‘use original image’ options from forms and models
  • Clarify help text for width, height, cropping, and upscaling to explain pixel format and aspect-ratio behavior
  • Rename the plugin tab from “Cropping” to “Dimensions” and rearrange fields accordingly

Chores:

  • Prune obsolete validation logic and model branches for removed options

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 17, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR reorganizes the image plugin UI by consolidating size-related controls into a new “Dimensions” tab, removes unused autoscaling and original-image options, updates help text for clarity, and cleans up related model and migration logic.

Entity relationship diagram for image plugin form fields after PR

erDiagram
    IMAGE_PLUGIN_FORM {
        INTEGER width
        INTEGER height
        STRING alignment
        STRING link_attributes
        BOOLEAN use_crop
        BOOLEAN use_upscale
        STRING use_responsive_image
        STRING thumbnail_options
    }
    IMAGE_PLUGIN_FORM ||--o| THUMBNAIL_OPTIONS : uses
    IMAGE_PLUGIN_FORM ||--o| RESPONSIVE_IMAGE : uses
Loading

Class diagram for updated ImagePlugin form fields

classDiagram
    class ImagePluginForm {
        - width: IntegerField
        - height: IntegerField
        - alignment: ChoiceField
        - link_attributes: CharField
        - use_crop: BooleanField
        - use_upscale: BooleanField
        - use_responsive_image: ChoiceField
        - thumbnail_options: ChoiceField
        + clean()
    }
    %% Removed fields
    %% use_automatic_scaling, use_no_cropping
    %% Updated help text for width, height, use_crop, use_upscale
Loading

Class diagram for updated Image model logic

classDiagram
    class Image {
        + get_size(width, height)
        + img_src()
        - use_automatic_scaling (removed)
        - use_no_cropping (removed)
    }
    %% get_size and img_src no longer depend on use_automatic_scaling or use_no_cropping
Loading

File-Level Changes

Change Details Files
Reorganized size controls into a new “Dimensions” tab
  • Renamed “Cropping” tab to “Dimensions”
  • Moved width/height fields into the Dimensions group
  • Removed width/height from the responsive image settings
djangocms_frontend/contrib/image/cms_plugins.py
Removed legacy autoscaling and original-image options
  • Deleted use_automatic_scaling and use_no_cropping form fields
  • Removed related invalid_option_pairs entries
  • Cleaned up model branches for automatic scaling and no cropping
  • Flagged legacy fields in image_save and migration scripts
djangocms_frontend/contrib/image/forms.py
djangocms_frontend/contrib/image/models.py
djangocms_frontend/contrib/image/image_save.py
djangocms_frontend/management/bootstrap4_migration.py
Enhanced help text for clarity on sizing and cropping
  • Expanded width help_text to specify pixel format
  • Updated height help_text to explain aspect ratio behavior and cropping
  • Clarified descriptions for use_crop and use_upscale
djangocms_frontend/contrib/image/forms.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Resolve the leftover “ask” comments and ensure the removal of use_automatic_scaling/use_no_cropping is consistently handled in image_save and bootstrap4_migration.
  • Fix the tab title overflow by either using a shorter label or adjusting the tab container’s width/CSS to prevent wrapping.
  • Confirm that removing the legacy scaling and cropping fields won’t break existing plugin instances—consider a data migration or default fallback for backward compatibility.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Resolve the leftover “ask” comments and ensure the removal of use_automatic_scaling/use_no_cropping is consistently handled in image_save and bootstrap4_migration.
- Fix the tab title overflow by either using a shorter label or adjusting the tab container’s width/CSS to prevent wrapping.
- Confirm that removing the legacy scaling and cropping fields won’t break existing plugin instances—consider a data migration or default fallback for backward compatibility.

## Individual Comments

### Comment 1
<location> `djangocms_frontend/contrib/image/forms.py:152` </location>
<code_context>
-    )
     # upscale and crop work together
     # throws validation error if other cropping options are selected
     use_crop = forms.BooleanField(
         label=_("Crop image"),
         required=False,
-        help_text=_("Crops the image according to the thumbnail settings provided in the template."),
+        help_text=_("Crops the image rather than resizing"),
     )
     use_upscale = forms.BooleanField(
</code_context>

<issue_to_address>
**suggestion:** The help text for 'use_crop' is now less descriptive.

The previous help text clarified that cropping is based on template thumbnail settings, which may be important for user understanding. Please review if the new wording is sufficiently informative.

```suggestion
        help_text=_("Crops the image according to the thumbnail settings provided in the template."),
```
</issue_to_address>

### Comment 2
<location> `djangocms_frontend/contrib/image/image_save.py:32` </location>
<code_context>
     img.config.update(
         {
             "picture": {"pk": image_obj.pk, "model": "filer.image"},
-            "use_no_cropping": True,
+            "use_no_cropping": True, # ask
         }
     )
</code_context>

<issue_to_address>
**question:** The comment '# ask' suggests uncertainty about the use of 'use_no_cropping'.

If 'use_no_cropping' is deprecated or its behavior has changed, please document its current usage to prevent confusion.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@fsbraun fsbraun changed the title Improvements to image plugin UI feat: Improved to image plugin UI Oct 17, 2025
@marbru marbru changed the title feat: Improved to image plugin UI feat: Improved image plugin UI Oct 20, 2025
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.00%. Comparing base (ec1da18) to head (7523196).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #316      +/-   ##
==========================================
- Coverage   89.13%   89.00%   -0.13%     
==========================================
  Files         124      124              
  Lines        3386     3383       -3     
  Branches      288      287       -1     
==========================================
- Hits         3018     3011       -7     
- Misses        252      256       +4     
  Partials      116      116              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fsbraun
Copy link
Member

fsbraun commented Oct 22, 2025

@marbru Once you remove the # ask comments, the pre-commit checks will pass.

Copy link
Member

@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, @marbru

@fsbraun fsbraun changed the title feat: Improved image plugin UI feat: Image plugin refactored for simpler size control Oct 24, 2025
@fsbraun fsbraun merged commit ddb5255 into django-cms:main Oct 28, 2025
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants