Make WordPress Core

Opened 6 years ago

Closed 14 months ago

#11101 closed enhancement (wontfix)

Gallery column width calculation needs more granularity

Reported by: akozak Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Gallery Keywords: gsoc has-patch needs-testing
Focuses: Cc:


In line 712 of wp-includes/media.php where the column width is calculated for the gallery css snippet:

$columns = intval($columns);
        $itemwidth = $columns > 0 ? floor(100/$columns) : 100;

        $selector = "gallery-{$instance}";

        $output = apply_filters('gallery_style', "
                <style type='text/css'>
                        #{$selector} {
                                margin: auto;
                        #{$selector} .gallery-item {
                                float: left;
                                margin-top: 10px;
                                text-align: center;
                                width: {$itemwidth}%;                   }

itemwidth should be calculated as

$itemwidth = $columns > 0 ? round(100/$columns,1) : 100;

This gives the width better precision. I've read that IE ignores the decimal, but it works on at least Firefox, so there is no reason not to let it have a decimal value. You could even increase the number of decimal points.

Attachments (2)

11101.diff (472 bytes) - added by wojtek.szkutnik 5 years ago.
11101.2.diff (713 bytes) - added by designsimply 5 years ago.

Download all attachments as: .zip

Change History (7)

#1 @scribu
6 years ago

  • Milestone changed from Unassigned to Future Release

#2 @wojtek.szkutnik
5 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords gsoc has-patch needs-testing added

Everything more than two decimal points gets cut to two.

Should work well on Mozilla, and not make any difference on Opera and IE. However, t needs heavy testing.

5 years ago

#3 @designsimply
5 years ago

The patch still had floor() instead of round(). Attached an updated patch, but also, is this really needed?

#4 @chriscct7
14 months ago

Why is this needed?

#5 @DrewAPicture
14 months ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.