[wp-trac] Re: [WordPress Trac] #2990: Inline Upload Image Size Attribute Problem For "Using Original"

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 30 19:33:17 GMT 2006


#2990: Inline Upload Image Size Attribute Problem For "Using Original"
----------------------------+-----------------------------------------------
 Reporter:  intoxination    |        Owner:  anonymous
     Type:  defect          |       Status:  closed   
 Priority:  normal          |    Milestone:           
Component:  Administration  |      Version:  2.0.4    
 Severity:  normal          |   Resolution:  fixed    
 Keywords:  upload image    |  
----------------------------+-----------------------------------------------
Changes (by Loknsiv):

  * resolution:  => fixed
  * keywords:  => upload image
  * status:  new => closed

Comment:

 I met the same problem and found the causes and solution:

 The following statement around line 432 is used to add quotation marks and
 it can't work properly:
 {{{
 h = h.replace(new RegExp('
 (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)',
 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
 }}}

 For example, if the string h is as below:
 {{{
 <img id=image1 height=96 alt=0011.jpg
 src="http://www.example.com/sample.png" width=128>
 }}}

 After the replacement it should be something as below:
 {{{
 <img id="image1" height="96" alt="0011.jpg"
 src="http://www.example.com/sample.png" width="128">
 }}}

 But in fact, for the replace statement can't work properly, the string h
 will be something as below after the replacement:
 {{{
 <img id="image1" height=96 alt=0011.jpg
 src="http://www.example.com/sample.png" width="128">
 }}}

 Just use the following replace statement instead of the original one can
 solve the problem perfectly:
 {{{
 h = h.replace(new RegExp('
 (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)',
 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
 }}}

 I hope I can explain the causes more clearly, but I'm Chinese and although
 I know something clearly but I could not express it clearly, so I can only
 give the examples and the solution, hoping anyone met the same problem
 could understand my solution.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2990>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list