[wp-trac] [WordPress Trac] #14577: wp_generate_tag_cloud() font-size generated with comma as decimal separator

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 10 09:27:00 UTC 2010


#14577: wp_generate_tag_cloud() font-size generated with comma as decimal separator
--------------------------+-------------------------------------------------
 Reporter:  elvarsteinn   |       Owner:                                                                             
     Type:  defect (bug)  |      Status:  new                                                                        
 Priority:  normal        |   Milestone:  Awaiting Review                                                            
Component:  General       |     Version:  3.0.1                                                                      
 Severity:  normal        |    Keywords:  wp_generate_tag_cloud tag cloud font size comma point category-template.php
--------------------------+-------------------------------------------------
 Hello,
 the wp_generate_tag_cloud() function in category-template.php was causing
 me problems since it returned style="font-size: 1,723828em" for example,
 and at least on FireFox 3.6 in MacOs the comma caused the browser to
 ignore the font-size attribute wholly, causing all but the largest tag
 (since that came down to an even 2em) to be the same size.

 I'm guessing that on other php Configurations (im on a server in Germany,
 where comma is the correct decimal separator) a point is returned by php
 as the decimal separator, and hence for people running english php
 configurations, this wouldn't be a problem. Also i assume some browsers /
 configurations dont mind getting the value with a comma separator, but
 mine did, and it isnt a very strange browser/OS combination im running.

 Bug (line 715-717 in category-template.php):
                 $a[] = "<a href='$tag_link' class='tag-link-$tag_id'
 title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "'
 style='font-size: " .
                         ( $smallest + ( ( $count - $min_count ) *
 $font_step ) )
                         . "$unit;'>$tag_name</a>";

 Fix:
                 $a[] = "<a href='$tag_link' class='tag-link-$tag_id'
 title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "'
 style='font-size: " .
                         number_format( ( $smallest + ( ( $count -
 $min_count ) * $font_step ) ), 3, '.', ',')
                         . "$unit;'>$tag_name</a>";


 Of course the rounding value of 3 could be chosen differently, or set to
 12 (? not sure) to not round at all (personally i feel you would never
 need more than 3 decimal places, and it does make the html look nicer).
 Alternatively, str_replace can replace a comma with a point.

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


More information about the wp-trac mailing list