Skip to content

Commit

Permalink
Normalize imageSizes string value if pg-picker has no picture
Browse files Browse the repository at this point in the history
  • Loading branch information
siimha committed Jun 26, 2018
1 parent a66ce49 commit c95e7dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
10 changes: 9 additions & 1 deletion javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,19 @@ MMCQ = (function() {
$(frontPageContent).find('.js-bgpicker-cover-color').css({'background-color' : frontPageContentBgColor});
};

var normalizeValue = function(value) {
if (value == null || (typeof value == 'string' && value.match(/^[\\'"]+$/))) {
return '';
} else {
return value;
}
};

// Header background image and color save logic function.
var frontPageContentCoverBgCommit = function(data, dataName) {
var commitData = $.extend(true, {}, data);
commitData.image = data.image || '';
commitData.imageSizes = data.imageSizes || '';
commitData.imageSizes = normalizeValue(data.imageSizes);
commitData.color = data.color || 'rgba(255,255,255,0)';
commitData.combinedLightness = frontPageContentCoverCombinedLightness;
pageData.set(dataName, commitData);
Expand Down
Loading

0 comments on commit c95e7dd

Please sign in to comment.