Changeset 32091
- Timestamp:
- 04/08/2015 10:27:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-controls.js
r32088 r32091 1693 1693 this.btnRemove.on( 'click', this.removeImage ); 1694 1694 1695 api.HeaderTool.currentHeader = new api.HeaderTool.ImageModel();1695 api.HeaderTool.currentHeader = this.getInitialHeaderImage(); 1696 1696 1697 1697 new api.HeaderTool.CurrentView({ … … 1714 1714 api.HeaderTool.DefaultsList 1715 1715 ]); 1716 }, 1717 1718 /** 1719 * Returns a new instance of api.HeaderTool.ImageModel based on the currently 1720 * saved header image (if any). 1721 * 1722 * @since 4.2.0 1723 * 1724 * @returns {Object} Options 1725 */ 1726 getInitialHeaderImage: function() { 1727 if ( ! api.get().header_image || ! api.get().header_image_data || _.contains( [ 'remove-header', 'random-default-image', 'random-uploaded-image' ], api.get().header_image ) ) { 1728 return new api.HeaderTool.ImageModel(); 1729 } 1730 1731 // Get the matching uploaded image object. 1732 var currentHeaderObject = _.find( _wpCustomizeHeader.uploads, function( imageObj ) { 1733 return ( imageObj.attachment_id === api.get().header_image_data.attachment_id ); 1734 } ); 1735 // Fall back to raw current header image. 1736 if ( ! currentHeaderObject ) { 1737 currentHeaderObject = { 1738 url: api.get().header_image, 1739 thumbnail_url: api.get().header_image, 1740 attachment_id: api.get().header_image_data.attachment_id 1741 }; 1742 } 1743 1744 return new api.HeaderTool.ImageModel({ 1745 header: currentHeaderObject, 1746 choice: currentHeaderObject.url.split( '/' ).pop() 1747 }); 1716 1748 }, 1717 1749
Note: See TracChangeset
for help on using the changeset viewer.