[wp-trac] [WordPress Trac] #13880: Custom Header Image Upload Bug

WordPress Trac wp-trac at lists.automattic.com
Mon Jun 14 06:48:00 UTC 2010


#13880: Custom Header Image Upload Bug
--------------------------+-------------------------------------------------
 Reporter:  CAMWebDesign  |       Owner:  ocean90    
     Type:  defect (bug)  |      Status:  assigned   
 Priority:  high          |   Milestone:  3.0        
Component:  Upload        |     Version:  3.0        
 Severity:  normal        |    Keywords:  needs-patch
--------------------------+-------------------------------------------------

Comment(by Eriksrocks):

 I did a little investigation on this issue and have come up with what may
 be a solution. At the very least it will help whoever this is assigned to
 in patching this issue. What's happening here is that the upload form on
 step 1 of the page has the same id ("upload") as the uploaded image that
 is displayed on step 2 for cropping.

 If the uploaded image already is already the size of the current header,
 the script displays the contents of the original "upload an image" page.
 However, because step 2 technically executed, the JavaScript for Step 2 is
 also output to the page (including the JavaScript for putting the cropping
 controls on the uploaded image with an ID of "upload"). This is where the
 conflict occurs - the JavaScript places the cropping controls on the
 upload form, because it has an ID of upload.

 The simple fix is to change the jQuery selectors so they only match an
 '''image''' with an ID of "upload", and thus no cropping controls appear
 over the upload box.

 These lines need to be changed in /wp-admin/custom-header.php:

 '''Line 374'''
 {{{
 var ximg = jQuery('#upload').width();
 }}}
 to
 {{{
 var ximg = jQuery('img#upload').width();
 }}}

 '''Line 375'''
 {{{
 var yimg = jQuery('#upload').height();
 }}}
 to
 {{{
 var yimg = jQuery('img#upload').height();
 }}}

 '''Line 387'''
 {{{
 jQuery('#upload').imgAreaSelect({
 }}}
 to
 {{{
 jQuery('img#upload').imgAreaSelect({
 }}}

 I've casually tested this. Upon uploading an image of the exact size, the
 cropping controls no longer appear over the file upload field, and normal
 cropping with non-perfectly-sized images still works as expected, so I
 don't think I've broken anything.

 I would patch to SVN but I don't have any experience in doing so and I'm
 not sure whether this is the proper fix, so I thought I would just post it
 here for review.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13880#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list