diff --git a/application/views/themeOptions/options_core.php b/application/views/themeOptions/options_core.php
index 22ecb3874f7..18a0f90c98d 100644
--- a/application/views/themeOptions/options_core.php
+++ b/application/views/themeOptions/options_core.php
@@ -4,13 +4,9 @@
$dropdown_options['font'] = ($bInherit ? '' . gT("Inherit") . ' [' . gT("inherited value:") . ' ' . (isset($oParentOptions['font']) ? $oParentOptions['font'] : '') . '] ' : '');
-
-
// background file
$backgroundImageFile = '';
- $backgroundfileOptionsInherit = '';
- $backgroundfileInheritPreview = '';
- $backgroundfileInheritFilename = '';
+ $backgroundfileInheritPreview = '';
$optgroup = '';
foreach($aTemplateConfiguration['imageFileList'] as $image){
if ($image['group'] != $optgroup){
@@ -22,10 +18,12 @@
}
$backgroundImageFile .= '';
- if (isset($oParentOptions['backgroundimagefile']) && $oParentOptions['backgroundimagefile'] == $image['filepath']){
- $backgroundfileInheritPreview = $backgroundfileInheritPreview . $image['preview'];
- $backgroundfileInheritFilename = $backgroundfileInheritFilename . $image['filename'];
+
+ if (isset($oParentOptions['backgroundimagefile']) && ($oParentOptions['backgroundimagefile'] == $image['filepath'] || $oParentOptions['backgroundimagefile'] == $image['filepathOptions'])) {
+
+ $backgroundfileInheritPreview = $image['preview'];
}
+
$backgroundImageFile .= '' . $image['filename'] . ' ';
}
@@ -33,9 +31,7 @@
// brand logo file
$brandlogo = '';
- $logofileOptionsInherit = '';
$logofileInheritPreview = '';
- $logofileInheritFilename = '';
$optgroup = '';
foreach($aTemplateConfiguration['imageFileList'] as $image){
if ($image['group'] != $optgroup){
@@ -47,10 +43,12 @@
}
$brandlogo .= '';
- if ($oParentOptions['brandlogo'] == $image['filepath']){
- $logofileInheritPreview = $logofileInheritPreview . $image['preview'];
- $logofileInheritFilename = $logofileInheritFilename . $image['filename'];
+
+ if (isset($oParentOptions['brandlogofile']) && ($oParentOptions['brandlogofile'] == $image['filepath'] || $oParentOptions['brandlogofile'] == $image['filepathOptions'])) {
+
+ $logofileInheritPreview = $image['preview'];
}
+
$brandlogo .= '' . $image['filename'] . ' ';
}
@@ -158,23 +156,39 @@
// TODO: $aParentOptions is not loaded properly, it seems.
$sParentOption = 'N/A';
}
+ $classes = [
+ 'form-control',
+ 'selector_option_value_field',
+ 'selector_radio_childfield',
+ ];
+ if ($category === 'Images') {
+ $classes[] = 'selector_image_selector';
+ }
+ $classValue = implode(' ', $classes);
echo '
- ';
+ ';
if ($bInherit){
- if ($attributeKey == 'backgroundimagefile'){
- $inheritedValue = isset($backgroundfileInheritPreview) ? $backgroundfileInheritPreview : '';
- } elseif ($attributeKey == 'backgroundimagefile'){
- $inheritedValue = isset($logofileInheritPreview) ? $logofileInheritPreview : '';
- } else {
- $inheritedValue = isset($sParentOption) ? $sParentOption : '';
+
+ $dataAttributes = '';
+ $lightboxSrc = '';
+ $inheritedValue = isset($sParentOption) ? $sParentOption : '';
+
+ if ($attributeKey == 'backgroundimagefile' && !empty($backgroundfileInheritPreview)){
+ $lightboxSrc = $backgroundfileInheritPreview;
+ } elseif ($attributeKey == 'brandlogofile' && !empty($logofileInheritPreview)) {
+ $lightboxSrc = $logofileInheritPreview;
}
- echo '' . gT("Inherit") . ' [' . gT("inherited value:") . ' ' . $inheritedValue . '] ';
+
+ if ($category === 'Images') {
+ $dataAttributes = 'data-lightbox-src="' . $lightboxSrc . '"';
+ }
+
+ echo '' . gT("Inherit") . ' [' . gT("inherited value:") . ' ' . $inheritedValue . '] ';
}
// dropdown options from config.xml file
echo $aOptionAttributes['optionAttributes'][$attributeKey]['dropdownoptions'];
echo '
';
-
} elseif ($attribute['type'] == 'icon'){
echo '
';
diff --git a/assets/packages/themeoptions-core/themeoptions-core.js b/assets/packages/themeoptions-core/themeoptions-core.js
index fa22808b1d8..8bfbf37decb 100644
--- a/assets/packages/themeoptions-core/themeoptions-core.js
+++ b/assets/packages/themeoptions-core/themeoptions-core.js
@@ -70,6 +70,20 @@ var ThemeOptions = function () {
optionObject[$(item).attr('name')] = $(item).val();
});
+ globalForm.find('.selector_image_selector').each(function (i, item) {
+ // disable the preview image button if the image
+ // selected could not be mapped to one of the images
+ // that actually exists within the theme
+ const src = $(item).find('option:selected').data('lightbox-src');
+ const missing = src === '';
+ const itemId = $(item).attr('id');
+ const button = $(`button[data-target="#${itemId}"]`);
+ button.prop('disabled', missing);
+
+ // add some feedback to the user, mark field invalid
+ $(item).parent().parent().toggleClass('has-error', missing);
+ });
+
globalForm.find('.selector_option_radio_field ').each(function (i, item) {
//disabled items should be inherit or false
if ($(item).prop('disabled')) {