mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-10 21:00:59 +01:00
d080076580
This restores the site icon setting to its original home on the settings page where it lives with the title and tagline. The base for this code was originally added in [32994] and then removed in [33329]. The majority of the modification to that version are to remove the no-js pieces and make the workflow completely inline rather than putting the cropping on a separate page. Additionally, since image crops rely on the ability to upload an image, this setting is gated by the `upload_files` capability. Follow-up to: [32994], [33329]. Props jorbin, audrasjb, mukesh27, joedolson, afercia, kebbet, swissspidy, obenland, jameskoster, kjellr, andraganescu, stacimc, mikeschroder, h71, krupajnanda, huzaifaalmesbah. Fixes #54370. See #16434. Built from https://develop.svn.wordpress.org/trunk@57602 git-svn-id: http://core.svn.wordpress.org/trunk@57103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
2.2 KiB
JavaScript
2 lines
2.2 KiB
JavaScript
/*! This file is auto-generated */
|
|
!function(a){var i;function t(t){var e=t.get("width"),t=t.get("height"),i=512,a=512,r=i/a,o=i,s=a;return r<e/t?i=(a=t)*r:a=(i=e)/r,{aspectRatio:i+":"+a,handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:e,imageHeight:t,minWidth:i<o?i:o,minHeight:a<s?a:s,x1:r=(e-i)/2,y1:o=(t-a)/2,x2:i+r,y2:a+o}}function r(i){var t;a("#site-icon-preview").find("img").not(".browser-preview").each(function(t,e){a(e).attr("src",i)}),a("#site-icon-preview").removeClass("hidden"),a("#js-remove-site-icon").removeClass("hidden"),"1"!==a("#choose-from-library-link").attr("data-state")&&(t=a("#choose-from-library-link").attr("class"),a("#choose-from-library-link").attr("class",a("#choose-from-library-link").attr("data-alt-classes")),a("#choose-from-library-link").attr("data-alt-classes",t),a("#choose-from-library-link").attr("data-state","1")),a("#choose-from-library-link").text(a("#choose-from-library-link").attr("data-update-text"))}a(function(){a("#choose-from-library-link").on("click",function(){var e=a(this);(i=wp.media({button:{text:e.data("update"),close:!1},states:[new wp.media.controller.Library({title:e.data("choose"),library:wp.media.query({type:"image"}),date:!1,suggestedWidth:e.data("size"),suggestedHeight:e.data("size")}),new wp.media.controller.SiteIconCropper({control:{params:{width:e.data("size"),height:e.data("size")}},imgSelectOptions:t})]})).on("cropped",function(t){a("#site_icon_hidden_field").val(t.id),r(t.url),i.close(),i=null}),i.on("select",function(){var t=i.state().get("selection").first();t.attributes.height===e.data("size")&&e.data("size")===t.attributes.width?(a("#site_icon_hidden_field").val(t.id),r(t.attributes.url),i.close()):i.setState("cropper")}),i.open()})}),a("#js-remove-site-icon").on("click",function(){a("#site_icon_hidden_field").val("false"),a("#site-icon-preview").toggleClass("hidden"),a(this).toggleClass("hidden");var t=a("#choose-from-library-link").attr("class");a("#choose-from-library-link").attr("class",a("#choose-from-library-link").attr("data-alt-classes")),a("#choose-from-library-link").attr("data-alt-classes",t),a("#choose-from-library-link").text(a("#choose-from-library-link").attr("data-choose-text")),a("#choose-from-library-link").attr("data-state","")})}(jQuery); |