Skip to content

feat: PORTAL_BLOG_SHOW_MAIN_IMAGE#1154

Draft
wesleyboar wants to merge 1 commit into
mainfrom
feat/PORTAL_BLOG_SHOW_MAIN_IMAGE
Draft

feat: PORTAL_BLOG_SHOW_MAIN_IMAGE#1154
wesleyboar wants to merge 1 commit into
mainfrom
feat/PORTAL_BLOG_SHOW_MAIN_IMAGE

Conversation

@wesleyboar
Copy link
Copy Markdown
Member

@wesleyboar wesleyboar commented May 13, 2026

Overview

Implements PORTAL_BLOG_SHOW_MAIN_IMAGE via CSS class: when False, adds no-visual to .app-blog and hides .blog-visual. Replaces per-portal custom stylesheets for this.

Caution

The display: none approach leaves .blog-visual and its <img> in the DOM. Problems:

  1. The browser still downloads the image even though it is hidden — and it downloads before any image the author explicitly placed in the article content.
  2. The layout-variant selector :--news-article-item:not(:has(.blog-visual > *)) in django.cms.blog.app.item.css never fires, because .blog-visual and its children are still present. This means the "no media" grid layout (which removes the phantom media column and its column-gap) is not applied to list-view articles.

Qodo also discovers these issues.

A fix would be to move the conditional into the templates (post_detail.html, blog_item.html) so the element is not rendered at all.

Related

Changes

  • added setting default and template context exposure in settings.py
  • added setting to settings_custom.example.py
  • added no-visual class to .app-blog in base.html when setting is False
  • added .app-blog.no-visual .blog-visual { display: none } in django.cms.blog.app.css

Testing

  1. Set PORTAL_BLOG_SHOW_MAIN_IMAGE = False in settings_custom.py.
  2. Open a blog article detail page; verify .blog-visual is hidden.
  3. Set to True; verify .blog-visual is visible.

UI

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add PORTAL_BLOG_SHOW_MAIN_IMAGE setting for blog image visibility control

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add PORTAL_BLOG_SHOW_MAIN_IMAGE setting to control blog article image visibility
• Implement CSS-based conditional hiding of .blog-visual element
• Expose setting in template context for conditional class application
• Update example configuration with new setting default
Diagram
flowchart LR
  A["settings.py<br/>Add PORTAL_BLOG_SHOW_MAIN_IMAGE"] --> B["Template context<br/>Expose setting"]
  B --> C["base.html<br/>Apply no-visual class"]
  C --> D["CSS<br/>Hide .blog-visual"]
  E["settings_custom.example.py<br/>Document setting"] -.-> A
Loading

Grey Divider

File Changes

1. taccsite_cms/settings/settings.py ⚙️ Configuration changes +5/-1

Add blog image visibility setting and expose to templates

• Add PORTAL_BLOG_SHOW_MAIN_IMAGE = False setting with explanatory comments
• Add setting to TEMPLATES_CONTEXT_PROCESSORS list for template exposure
• Reorder context processor list to group related blog settings

taccsite_cms/settings/settings.py


2. taccsite_cms/settings/settings_custom.example.py 📝 Documentation +1/-0

Document new blog image visibility setting

• Add PORTAL_BLOG_SHOW_MAIN_IMAGE = False to example configuration
• Document the new setting for portal administrators

taccsite_cms/settings/settings_custom.example.py


3. taccsite_cms/templates/djangocms_blog/base.html ✨ Enhancement +1/-0

Apply conditional CSS class for image visibility

• Add conditional no-visual CSS class to .app-blog container
• Class applied when PORTAL_BLOG_SHOW_MAIN_IMAGE is False
• Follows existing pattern for no-categories and no-tags classes

taccsite_cms/templates/djangocms_blog/base.html


View more (1)
4. taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css ✨ Enhancement +3/-2

Add CSS rule to hide blog visual element

• Add .app-blog.no-visual .blog-visual { display: none } CSS rule
• Update comment to reflect all conditional hiding use cases
• Hides blog visual element via CSS when setting is disabled

taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented May 13, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0)

Grey Divider


Action required

1. No-visual keeps media layout 🐞 Bug ≡ Correctness
Description
Blog list items switch to a special “no media” layout only when the article has no .blog-visual
children, but the PR’s CSS hide keeps those children in the DOM. As a result, the no-media layout
rule will not apply when no-visual is enabled, likely leaving empty media grid space/misaligned
list items.
Code

taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[R82-87]

+/* To conditionally hide certain content */
.app-blog.no-tags .tags,
-.app-blog.no-categories .categories {
+.app-blog.no-categories .categories,
+.app-blog.no-visual .blog-visual {
  display: none;
}
Evidence
List items always render .blog-visual with child <img> elements, and the PR only hides it with
display:none. The list CSS applies the no-media layout only when :has(.blog-visual > *) is
false, which will not happen when images are merely hidden.

taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[82-87]
taccsite_cms/templates/djangocms_blog/includes/blog_item.html[17-28]
taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.item.css[69-103]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The feed layout uses `:--news-article-item:not(:has(.blog-visual > *))` to detect when a list item has no media and apply `news-feed__article--no-media`. With `no-visual`, `.blog-visual` is hidden but still contains children, so this detection never triggers.

## Issue Context
The PR hides `.blog-visual` via `display:none`, but does not remove the markup. Existing CSS depends on DOM presence to decide layout.

## Fix Focus Areas
- taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[82-87]
- taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.item.css[69-103]
- taccsite_cms/templates/djangocms_blog/includes/blog_item.html[17-28]

## Expected fix
Preferably: stop rendering `.blog-visual` when `PORTAL_BLOG_SHOW_MAIN_IMAGE` is false (template-gated rendering). This will automatically make the `:has(.blog-visual > *)` condition false and enable the correct no-media layout.

If you must keep CSS-only hiding: add an explicit override for no-visual mode to apply the no-media layout mixin (or an equivalent grid/template adjustment) for list items when `.app-blog.no-visual` is present.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Hidden images still download 🐞 Bug ➹ Performance
Description
The new no-visual mode hides .blog-visual with CSS but still renders the <img> tags in templates, so
browsers will still request/download the main/preview images. This increases bandwidth and can hurt
page performance (e.g., LCP) even though the image is not visible.
Code

taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[R82-87]

+/* To conditionally hide certain content */
.app-blog.no-tags .tags,
-.app-blog.no-categories .categories {
+.app-blog.no-categories .categories,
+.app-blog.no-visual .blog-visual {
  display: none;
}
Evidence
The PR adds a no-visual class and a CSS rule that hides .blog-visual, but .blog-visual still
contains <img src=...> in both the detail and list-item templates, meaning the browser will still
fetch those image URLs.

taccsite_cms/templates/djangocms_blog/base.html[31-37]
taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[82-87]
taccsite_cms/templates/djangocms_blog/post_detail.html[45-52]
taccsite_cms/templates/djangocms_blog/includes/blog_item.html[17-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PORTAL_BLOG_SHOW_MAIN_IMAGE=False` currently only applies `display:none` to `.blog-visual`, leaving `<img>` elements in the DOM and still downloading their resources.

## Issue Context
The templates always render a `.blog-visual` container with thumbnails/media, and the PR change hides it only via CSS.

## Fix Focus Areas
- taccsite_cms/templates/djangocms_blog/post_detail.html[45-52]
- taccsite_cms/templates/djangocms_blog/includes/blog_item.html[17-28]
- taccsite_cms/templates/djangocms_blog/base.html[31-37]
- taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[82-87]

## Expected fix
Wrap the `.blog-visual` rendering blocks in `{% if settings.PORTAL_BLOG_SHOW_MAIN_IMAGE %}...{% endif %}` (or a more nuanced condition if some media should still show), so the element is not rendered when disabled. Then either remove the CSS hide rule or keep it as a defensive fallback.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@wesleyboar wesleyboar marked this pull request as draft May 13, 2026 01:04
Comment on lines +82 to 87
/* To conditionally hide certain content */
.app-blog.no-tags .tags,
.app-blog.no-categories .categories {
.app-blog.no-categories .categories,
.app-blog.no-visual .blog-visual {
display: none;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. No-visual keeps media layout 🐞 Bug ≡ Correctness

Blog list items switch to a special “no media” layout only when the article has no .blog-visual
children, but the PR’s CSS hide keeps those children in the DOM. As a result, the no-media layout
rule will not apply when no-visual is enabled, likely leaving empty media grid space/misaligned
list items.
Agent Prompt
## Issue description
The feed layout uses `:--news-article-item:not(:has(.blog-visual > *))` to detect when a list item has no media and apply `news-feed__article--no-media`. With `no-visual`, `.blog-visual` is hidden but still contains children, so this detection never triggers.

## Issue Context
The PR hides `.blog-visual` via `display:none`, but does not remove the markup. Existing CSS depends on DOM presence to decide layout.

## Fix Focus Areas
- taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.css[82-87]
- taccsite_cms/static/site_cms/css/src/_imports/components/django.cms.blog.app.item.css[69-103]
- taccsite_cms/templates/djangocms_blog/includes/blog_item.html[17-28]

## Expected fix
Preferably: stop rendering `.blog-visual` when `PORTAL_BLOG_SHOW_MAIN_IMAGE` is false (template-gated rendering). This will automatically make the `:has(.blog-visual > *)` condition false and enable the correct no-media layout.

If you must keep CSS-only hiding: add an explicit override for no-visual mode to apply the no-media layout mixin (or an equivalent grid/template adjustment) for list items when `.app-blog.no-visual` is present.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

1 participant