From a13b695fbd158ec24cb46484bdaaf9d1263b4532 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Fri, 25 Apr 2014 20:24:28 +0000 Subject: [PATCH] Customizer: Allow to skip cropping header images if image width is smaller than or equal to theme width. Add tests. see #27936 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@28219 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/customize-models.js | 4 ++++ tests/qunit/wp-admin/js/customize-header.js | 23 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/wp-includes/js/customize-models.js b/src/wp-includes/js/customize-models.js index 5fa62aeecc..5969be3963 100644 --- a/src/wp-includes/js/customize-models.js +++ b/src/wp-includes/js/customize-models.js @@ -113,6 +113,10 @@ return false; } + if (this.get('imageWidth') <= this.get('themeWidth')) { + return false; + } + return true; } }); diff --git a/tests/qunit/wp-admin/js/customize-header.js b/tests/qunit/wp-admin/js/customize-header.js index ba2895f47e..d5f01100f8 100644 --- a/tests/qunit/wp-admin/js/customize-header.js +++ b/tests/qunit/wp-admin/js/customize-header.js @@ -103,6 +103,29 @@ jQuery( function() { imageWidth: 10000, imageHeight: 8600 }); + + equal(this.model.shouldBeCropped(), false); + }); + + test('should not be cropped when the image width is smaller than or equal to theme width', function() { + this.model.set({ + themeFlexWidth: false, + themeFlexHeight: false, + imageWidth: 1000, + imageHeight: 100 + }); + + equal(this.model.shouldBeCropped(), false); + }); + + test('should not be cropped when the image width is smaller than or equal to theme width, theme supports flex height and width', function() { + this.model.set({ + themeFlexWidth: true, + themeFlexHeight: true, + imageWidth: 900, + imageHeight: 100 + }); + equal(this.model.shouldBeCropped(), false); }); });