fix(mixedimage): TV preview after reload in MODX 3 (#35) - #45
Open
Ibochkarev wants to merge 1 commit into
Open
Conversation
Normalize boolean TV options for modx-combo-boolean values, init preview on panel afterrender, and fix phpThumb URL/source placeholders in tpl. Fixes webinmd#35
Ibochkarev
marked this pull request as ready for review
August 9, 2026 04:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
После сохранения ресурса и перезагрузки страницы в MODX 3 превью mixedImage пропадало, хотя путь к файлу в TV оставался. PR закрывает #35.
Зачем
В MODX 3 boolean-опции TV (
showPreviewи др.) хранятся как1/0черезmodx-combo-boolean. Старый код сравнивал их только сlexicon('yes'). В tpl блок превью не попадал в DOM, в JSshowPreviewстановилсяfalse.Даже при корректном SSR-превью JS не вызывал
updatePreviewпри загрузке страницы. Превью обновлялось только после upload/crop/browser select.В tpl phpThumb брал
{$_config.connectors_url}и{$tv->source}. В MODX 3 manager Smarty эти значения часто пустые или неверные.Что сделано
PHP —
mixedimage.class.phpisYesOption()/toJsBoolean()— нормализация boolean для MODX 2 и 3 (1,yes,true, lexicon).connectors_urlиз$modx->getOption('connectors_url')вместо Smarty$_config.mime_content_type()только если файл существует (без warning на пустом value).Tpl —
mixedimage.tpl{$connectors_url},source={$ms_id},srcсescape:'url'.source: {$ms_id}вместо строки из$tv->source.JS —
mixedimage.jsisPreviewEnabled,getFileExtensionInfo,buildPreviewContent,updatePreviewElement.afterrenderс текущимvalue.updatePreview.UX
Поведение upload/crop/clear не менялось. Меняется только восстановление превью после reload и корректность SSR-картинки.
Scope
Ветка содержит только изменения для #35. Не затрагивает crop (#31) и remove/replace (#17).
На ревью
showPreview = Даи default1из combo-boolean.Fixes #35