public function get_current_row_size() { $images_left = count($this->images); if ($images_left < 3) { return array_fill(0, $images_left, 1); } foreach (array('One_Three', 'One_Two', 'Five', 'Four', 'Three', 'Two_One', 'Symmetric_Row', 'Panoramic') as $shape_name) { $class_name = "Jetpack_Tiled_Gallery_{$shape_name}"; $shape = new $class_name($this->images); if ($shape->is_possible()) { Jetpack_Tiled_Gallery_Shape::set_last_shape($class_name); return $shape->shape; } } Jetpack_Tiled_Gallery_Shape::set_last_shape('Two'); return array(1, 1); }
public function get_current_row_size() { $images_left = count($this->images); if ($images_left < 3) { return array_fill(0, $images_left, 1); } foreach ($this->shapes as $shape_name) { $class_name = "Jetpack_Tiled_Gallery_{$shape_name}"; $shape = new $class_name($this->images); if ($shape->is_possible()) { Jetpack_Tiled_Gallery_Shape::set_last_shape($class_name); return $shape->shape; } } Jetpack_Tiled_Gallery_Shape::set_last_shape('Two'); return array(1, 1); }
public function __construct($images) { parent::__construct($images); $total_ratio = $this->sum_ratios($this->images_left); $approximate_column_ratio = $total_ratio / 3; $column_one_images = $column_two_images = $column_three_images = $sum = 0; foreach ($this->images as $image) { if ($sum <= $approximate_column_ratio) { $column_one_images++; } if ($sum > $approximate_column_ratio && $sum <= 2 * $approximate_column_ratio) { $column_two_images++; } $sum += $image->ratio; } $column_three_images = $this->images_left - $column_two_images - $column_one_images; if ($column_one_images) { $this->shape[] = $column_one_images; } if ($column_two_images) { $this->shape[] = $column_two_images; } if ($column_three_images) { $this->shape[] = $column_three_images; } }
public static function reset_last_shape() { self::$shapes_used = array(); }