layout = 'cascade'; } function prepare_layouts() { $this->layouts = [ 'o', 'i', 'ii' ]; } function inline_css() { $class_id = '#' . $this->class_id; $gutter = isset( $this->atts['gutter'] ) ? $this->atts['gutter'] : get_option( 'mgl_cascade_gutter', 10 ); $isPreview = $this->isPreview; ob_start(); include dirname( __FILE__ ) . '/cascade.css.php'; $html = ob_get_clean(); return $html; } function get_layout( $ids ) { $ids = array_reverse( $ids ); $layout = ""; foreach ( $ids as $id ) $layout .= $this->data[$id]['meta']['width'] >= $this->data[$id]['meta']['height'] ? 'o' : 'i'; return $layout; } function build_next_cell( $id, $data ) { $html = parent::build_next_cell( $id, $data ); $html = str_replace( '100vw', 100 / 3 . 'vw', $html ); return $html; } function build( $idsStr ) { // Generate gallery $classes = $this->build_classes(); $styles = $this->build_styles(); $out = "
"; $this->prepare_data( $idsStr ); $this->prepare_layouts(); $ooo_v = 0; while ( count( $this->ids ) > 0 ) { $size = 2; $layout = null; $ideal = "N/A"; while ( !$layout && $size > 0 ) { // Look for exact layout $size-cols $currentIds = array_slice( $this->ids, $size * -1, $size, true ); $ideal = $this->get_layout( $currentIds ); if ( in_array( $ideal, $this->layouts ) ) { $layout = $ideal; break; } $size--; } // Display an error if the layout does not exist if ( !$layout ) { echo( '
MEOW GALLERY ERROR. No layout for '. $ideal . '.
' ); $layout = $ideal; } // Create row with cells inside it (using the order in currentIds) $count = 0; $out .= '
'; while ( count( $currentIds ) > 0 ) { $out .= '
'; $id = array_pop( $this->ids ); $id = array_pop( $currentIds ); $out .= $this->build_next_cell( $id, $this->data[$id] ); $out .= '
'; } $out .= '
'; } $out .= '
'; $out = apply_filters( 'mgl_gallery_written', $out, $this->layout ); // Generate gallery container $container_classes = $this->build_container_classes(); $inline_css = $this->inline_css(); $container = "
{$inline_css}{$out}
"; return $container; } } ?>