public function __construct($attachments, $shapes = array())
 {
     $content_width = WP_Galleries::get_content_width();
     $ua_info = new Jetpack_User_Agent_Info();
     $this->overwrite_shapes($shapes);
     $this->last_shape = '';
     $this->images = $this->get_images_with_sizes($attachments);
     $this->grouped_images = $this->get_grouped_images();
     $this->apply_content_width($content_width);
 }
 private function compute_items()
 {
     $content_width = WP_Galleries::get_content_width();
     $images_per_row = $this->columns;
     $margin = 2;
     $margin_space = $images_per_row * $margin * 2;
     $size = floor(($content_width - $margin_space) / $images_per_row);
     $img_size = $remainder_size = $size;
     $remainder = count($this->attachments) % $images_per_row;
     if ($remainder > 0) {
         $remainder_space = $remainder * $margin * 2;
         $remainder_size = floor(($content_width - $remainder_space) / $remainder);
     }
     $c = 1;
     $items_in_row = 0;
     $rows = array();
     $row = new stdClass();
     $row->images = array();
     foreach ($this->attachments as $image) {
         if ($remainder > 0 && $c <= $remainder) {
             $img_size = $remainder_size;
         } else {
             $img_size = $size;
         }
         $image->width = $image->height = $img_size;
         $item = new Jetpack_Tiled_Gallery_Square_Item($image, $this->needs_attachment_link, $this->grayscale);
         $row->images[] = $item;
         $c++;
         $items_in_row++;
         if ($images_per_row === $items_in_row || $remainder + 1 == $c) {
             $rows[] = $row;
             $items_in_row = 0;
             $row->height = $img_size + $margin * 2;
             $row->width = $content_width;
             $row->group_size = $img_size + 2 * $margin;
             $row = new stdClass();
             $row->images = array();
         }
     }
     if (!empty($row->images)) {
         $row->height = $img_size + $margin * 2;
         $row->width = $content_width;
         $row->group_size = $img_size + 2 * $margin;
         $rows[] = $row;
     }
     return $rows;
 }
if (defined('JSON_HEX_AMP')) {
    // see shortcodes/slideshow.php
    // This is nice to have, but not strictly necessary since we use _wp_specialchars() below
    $extra = json_encode($this->get_container_extra_data(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
} else {
    $extra = json_encode($this->get_container_extra_data());
}
?>
<div
	class="tiled-gallery type-<?php 
echo $this->type;
?>
 tiled-gallery-unresized"
	data-original-width="<?php 
echo esc_attr(WP_Galleries::get_content_width());
?>
"
	<?php 
if (isset($extra)) {
    ?>
		data-carousel-extra='<?php 
    echo _wp_specialchars(wp_check_invalid_utf8($extra), ENT_QUOTES, false, true);
    ?>
'
	<?php 
}
?>
	>
	<?php 
$this->template("{$this->type}-layout", $context);