Skip to content

Expose image dimensions for theme settings - #391

Merged
PercolatingStudio merged 1 commit into
mainfrom
codex/issue-273-theme-image-metadata
Nov 24, 2026
Merged

PercolatingStudio merged 1 commit into
mainfrom
codex/issue-273-theme-image-metadata

Conversation

@PercolatingStudio

Copy link
Copy Markdown
Owner

Fixes #273.

Reproduction

Install PrettyBlocks 3.2.6 and register a global theme setting of type fileupload with a local PNG as default.url. The back-office field can display its default, but the flat $theme_settings value passed to templates comes from raw storage: before the field is saved it omits the default, and after save it has no measured dimensions. The same file works in a block field.

Fix

Use the existing front-office fileupload formatter for flat public theme settings of this type. It resolves local images using the same shop/path guards as blocks and supplies size, width and height. Other field types and the back-office settings payload retain their current behavior. An explicitly cleared image does not restore its default.

Validation

  • PrestaShop 8.2.7/PHP 8.1.33 and PrestaShop 9.1.4/PHP 8.5.0: actual theme-setting hook and Smarty template. On the published 3.2.6 archive the default is missing and the saved PNG has no dimensions. With the candidate the 57×57 PNG (4,564 bytes) has URL, dimensions and size in both cases. The saved value from the old package survives the in-place replacement.
  • The new PHP regression test fails before and passes after, including the unchanged false value for a setting with no image, preservation of explicit clears, and unchanged back-office behavior.
  • All 60 Node tests pass. The same candidate ZIP (SHA-256 53b966012e6a73b2bc47ad23a6efafdd215102c518d91561544f817948196859) was extracted by PrestaShop’s ZIP handler on both shops; prettyblocks/, the Vite manifest and its assets were checked.

Scope

This fixes the theme-setting path for images whose dimensions are supported by the existing formatter. It does not introduce SVG dimension parsing, fetch remote images, change write paths, or change the module version.

@PercolatingStudio
PercolatingStudio merged commit f6989ee into main Nov 24, 2026
6 checks passed
@PercolatingStudio
PercolatingStudio deleted the codex/issue-273-theme-image-metadata branch November 24, 2026 08:44
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.

Impossible to retrieve default image width and height attributes from fileupload field

1 participant