Exemplo n.º 1
0
 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') as $shape_name) {
         $class_name = "themePacific_Jetpack_Tiled_Gallery_{$shape_name}";
         $shape = new $class_name($this->images);
         if ($shape->is_possible()) {
             themePacific_Jetpack_Tiled_Gallery_Shape::set_last_shape($class_name);
             return $shape->shape;
         }
     }
     themePacific_Jetpack_Tiled_Gallery_Shape::set_last_shape('Two');
     return array(1, 1);
 }
Exemplo n.º 2
0
}
if (isset($id)) {
    $tvf = $modx->getTemplateVar($tvname, '*', $id);
    $tvv = $tvf['value'];
} else {
    $id = $modx->documentObject['id'];
    $tvf = $modx->documentObject[$tvname];
    $tvv = $tvf[1];
}
if (!$tvv || $tvv == '[]') {
    return;
}
$attachments = json_decode($tvv);
include_once MODX_BASE_PATH . 'assets/snippets/tiledphotos/tiledphotos.class.php';
$grouper = new themePacific_Jetpack_Tiled_Gallery_Grouper($attachments, $modx);
themePacific_Jetpack_Tiled_Gallery_Shape::reset_last_shape();
$rows = '';
$num = 1;
foreach ($grouper->grouped_images as $row) {
    $groups = '';
    foreach ($row->groups as $group) {
        $count = count($group->images);
        $wrap = '';
        foreach ($group->images as $image) {
            $size = 'large';
            if ($image->width < 250) {
                $size = 'small';
            }
            $image_title = $image->post_title;
            $link = $image->image_url;
            $img_src = $modx->runSnippet('phpthumb', array('input' => $link, 'options' => 'w=' . $image->width . '&h=' . $image->height . '&zc=C'));
Exemplo n.º 3
0
 public function calculate_image_sizes($group)
 {
     // Storing the calculated image heights in an array for rounding them later while preserving their sum
     // This fixes the rounding error that can lead to a few ugly pixels sticking out in the gallery
     $image_heights_array = array();
     foreach ($group->images as $image) {
         $image->width = $group->width - $this->margin;
         // Storing the raw calculations in a separate property for diagnostics
         $image->raw_height = ($group->raw_width - $this->margin) / $image->ratio;
         $image_heights_array[] = $image->raw_height;
     }
     $image_height_sum = $group->height - count($image_heights_array) * $this->margin;
     $rounded_image_heights_array = themePacific_Jetpack_Tiled_Gallery_Shape::get_rounded_constrained_array($image_heights_array, $image_height_sum);
     foreach ($group->images as $image) {
         $image->height = array_shift($rounded_image_heights_array);
     }
 }