Jetpack_Tiled_Gallery_Three_Columns

The Jetpack by WordPress.com Jetpack Tiled Gallery Three Columns class.

Defined (1)

The class is defined in the following location(s).

/modules/tiled-gallery/tiled-gallery/tiled-gallery-shape.php  
  1. class Jetpack_Tiled_Gallery_Three_Columns extends Jetpack_Tiled_Gallery_Shape { 
  2. public $shape = array(); 
  3.  
  4. public function __construct( $images ) { 
  5. parent::__construct( $images ); 
  6.  
  7. $total_ratio = $this->sum_ratios( $this->images_left ); 
  8. $approximate_column_ratio = $total_ratio / 3; 
  9. $column_one_images = $column_two_images = $column_three_images = $sum = 0; 
  10.  
  11. foreach ( $this->images as $image ) { 
  12. if ( $sum <= $approximate_column_ratio ) { 
  13. $column_one_images++; 
  14.  
  15. if ( $sum > $approximate_column_ratio && $sum <= 2 * $approximate_column_ratio ) { 
  16. $column_two_images++; 
  17. $sum += $image->ratio; 
  18.  
  19. $column_three_images = $this->images_left - $column_two_images - $column_one_images; 
  20.  
  21. if ( $column_one_images ) { 
  22. $this->shape[] = $column_one_images; 
  23.  
  24. if ( $column_two_images ) { 
  25. $this->shape[] = $column_two_images; 
  26.  
  27. if ( $column_three_images ) { 
  28. $this->shape[] = $column_three_images; 
  29.  
  30. public function is_possible() { 
  31. return ! empty( $this->shape );