Ticket #20258: 20258.diff
| File 20258.diff, 7.3 KB (added by , 14 years ago) |
|---|
-
wp-admin/includes/media.php
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 79bd1a9..33f0a17 100644
a b jQuery(function($){ 1764 1764 </select> 1765 1765 </td> 1766 1766 </tr> 1767 <tr> 1768 <th scope="row" class="label"> 1769 <label> 1770 <span class="alignleft"><?php _e('Image Size:'); ?></span> 1771 </label> 1772 </th> 1773 <td class="field"> 1774 <select id="image_size" name="image_size" size="1"> 1775 <?php $sizes = get_intermediate_image_sizes(); 1776 foreach ($sizes as $size) : ?> 1777 <option value="<?php echo $size?>"><?php echo _e( ucfirst( $size ) ); ?></option> 1778 <?php endforeach; ?> 1779 </select> 1780 </td> 1781 </tr> 1782 <tr> 1783 <th scope="row" class="label"> 1784 <label> 1785 <span class="alignleft"><?php _e('Display:'); ?></span> 1786 </label> 1787 </th> 1788 <td class="field"> 1789 <input type="radio" checked="checked" name="display" id="display-all" value="all" /> 1790 <label for="display-all" class="radio"><?php _e('All'); ?></label> 1791 1792 <input type="radio" name="display" id="display-include" value="include" /> 1793 <label for="display-include" class="radio"><?php _e('Include'); ?></label> 1794 1795 <input type="radio" name="display" id="display-exclude" value="exclude" /> 1796 <label for="display-exclude" class="radio"><?php _e('Exclude'); ?></label> 1797 <div id="gallery_ids_wrapper" style="display:none;" > 1798 <?php 1799 $attachments = array(); 1800 if ( $post_id ) { 1801 $post = get_post($post_id); 1802 if ( $post && $post->post_type == 'attachment' ) 1803 $attachments = array($post->ID => $post); 1804 else 1805 $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); 1806 } else { 1807 if ( is_array($GLOBALS['wp_the_query']->posts) ) 1808 foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) 1809 $attachments[$attachment->ID] = $attachment; 1810 } 1811 1812 $output = ''; 1813 foreach ( (array) $attachments as $id => $attachment ) { 1814 if ( $attachment->post_status == 'trash' ) 1815 continue; 1816 if (TRUE == ( $title = get_the_title($id) ) ) 1817 $output .= '<span style="float:left;"><input type="checkbox" name="gallery_ids['. $id .']" class="gallery_ids" id="gallery_id'. $id .'">'; 1818 $output .= '<label for="gallery_id' . $id . '">' . $title . '</label></span>'; 1819 } 1820 ?> 1821 <?php echo $output; ?> 1822 </div> 1823 </td> 1824 </tr> 1767 1825 </tbody></table> 1768 1826 1769 1827 <p class="ml-submit"> -
wp-admin/js/gallery.dev.js
diff --git a/wp-admin/js/gallery.dev.js b/wp-admin/js/gallery.dev.js index d7b4bb1..5d73e3a 100644
a b jQuery(document).ready(function($) { 67 67 $('#insert-gallery').show(); 68 68 } 69 69 } 70 //Setup the display options chooser 71 $("input[name=display]").click(function (e) { 72 var $target = $(e.target), 73 val = $target.val(), 74 $id_wrapper = $("#gallery_ids_wrapper"); 75 if (val == "include" || val == "exclude") { 76 $id_wrapper.slideDown(); 77 } else { 78 $id_wrapper.slideUp(); 79 } 80 }); 70 81 }); 71 82 72 83 jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup … … wpgallery = { 122 133 if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) { 123 134 t.el = g[0]; 124 135 } else { 136 //Set current options 125 137 if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked"; 126 138 if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked"; 127 139 if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols'); 128 140 if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord'); 141 129 142 jQuery('#insert-gallery').show(); 130 143 return; 131 144 } … … wpgallery = { 135 148 a = ed.dom.decode(a); 136 149 137 150 if ( a ) { 151 //There is already a gallery in the selection 152 //Update the UI to reflect the current shortcode 138 153 jQuery('#update-gallery').show(); 139 154 t.is_update = true; 140 155 … … wpgallery = { 142 157 link = a.match(/link=['"]([^'"]+)['"]/i); 143 158 order = a.match(/order=['"]([^'"]+)['"]/i); 144 159 orderby = a.match(/orderby=['"]([^'"]+)['"]/i); 160 161 include = a.match(/include=['"]([^'"]+)['"]/i); 162 exclude = a.match(/exclude=['"]([^'"]+)['"]/i); 163 size = a.match(/size=['"]([^'"]+)['"]/i); 145 164 146 165 if ( link && link[1] ) t.I('linkto-file').checked = "checked"; 147 166 if ( order && order[1] ) t.I('order-desc').checked = "checked"; 148 167 if ( columns && columns[1] ) t.I('columns').value = ''+columns[1]; 149 168 if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1]; 169 if ( size && size[1] ) t.I('image_size').value = size[1]; 170 171 172 if (include || exclude ) 173 jQuery("#gallery_ids_wrapper").show(); 174 if (include && include[1]) { 175 var ids = include[1].split(','); 176 jQuery.each(ids, function (k,v) { 177 jQuery("#gallery_id"+v).attr('checked','checked'); 178 }) 179 jQuery('#display-include').trigger('click') 180 } 181 if (exclude && exclude[1]) { 182 var ids = exclude[1].split(','); 183 jQuery.each(ids, function (k,v) { 184 jQuery("#gallery_id"+v).attr('checked','checked'); 185 }) 186 jQuery('#display-exclude').trigger('click') 187 } 150 188 } else { 151 189 jQuery('#insert-gallery').show(); 152 190 } … … wpgallery = { 164 202 if (t.el.nodeName != 'IMG') return; 165 203 166 204 all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title')); 167 all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, ''); 205 //Remove original shortcode options 206 all = all.replace(/\s*(order|link|columns|orderby|include|exclude|size)=['"]([^'"]+)['"]/gi, ''); 207 //Get the new settings 168 208 all += t.getSettings(); 169 209 170 210 ed.dom.setAttrib(t.el, 'title', all); … … wpgallery = { 172 212 }, 173 213 174 214 getSettings : function() { 175 var I = this.I, s = ''; 176 215 var I = this.I, //document.GetElementbyID 216 s = '', //Shortcode Setting String (returned); 217 ids = [];//Attachment ids for include/exclude 177 218 if ( I('linkto-file').checked ) { 178 219 s += ' link="file"'; 179 220 setUserSetting('galfile', '1'); … … wpgallery = { 188 229 s += ' columns="'+I('columns').value+'"'; 189 230 setUserSetting('galcols', I('columns').value); 190 231 } 191 192 if ( I('orderby').value != 'menu_order' ) { 193 s += ' orderby="'+I('orderby').value+'"'; 194 setUserSetting('galord', I('orderby').value); 232 if ( I('image_size').value != 'thumbnail' ) { 233 s += ' size="'+I('image_size').value+'"'; 234 setUserSetting('galimage_size', I('image_size').value); 235 } 236 if (! I('display-all').checked ) { 237 //We're filtering the result set for an include/exclude 238 var $ids = jQuery(".gallery_ids");//jQuery array 239 jQuery.each($ids, function (k,checkbox) { 240 if (checkbox.checked) { 241 //cache the attachment ids to include/exclude 242 ids[k] = checkbox.id.replace('gallery_id','');//Get the numeric id 243 } 244 }); 245 } 246 if ( I('display-all').checked ) { 247 setUserSetting('galdisplay', 'all'); 248 } else if ( I('display-include').checked ) { 249 //Gallery Shortcode Include 250 if (! ids.length == 0 ) 251 { 252 s += ' include="'+ ids.join(',') + '"'; 253 setUserSetting('galdisplay', 'include=' + ids.join(',') ); 254 255 } 256 } else if ( I('display-exclude').checked ){ 257 //Gallery Shortcode Exclude 258 if (! ids.length == 0 ) 259 { 260 s += ' exclude="'+ ids.join(',') + '"'; 261 setUserSetting('galdisplay', 'exclude=' + ids.join(',') ); 262 } 195 263 } 196 264 197 265 return s; 198 266 } 199 }; 267 }; 268 No newline at end of file