' . esc_html__( 'Image Gallery', 'hello-wpstream' ) . ''; } // Generate the gallery HTML and return it as a string. return wpstream_theme_image_generate_fancybox( $gallery_images, $full_size ); } } if ( ! function_exists( 'wpstream_theme_image_generate_fancybox' ) ) { /** * Generate HTML for a gallery using FancyBox. * * @param array $image_ids Array of attachment IDs for the images in the gallery. * @param string $full_size The size of the full-size images. * @return string Returns the HTML for the gallery. */ function wpstream_theme_image_generate_fancybox( $image_ids, $full_size = 'full' ) { if ( empty( $image_ids ) ) { return; } $output = '
'; $output .= '
'; // Generate links to open images in FancyBox. foreach ( $image_ids as $image_id ) { $wpstream_featured_unit_cards = wp_get_attachment_image_src( $image_id, 'wpstream_featured_unit_cards' ); $image_src = wp_get_attachment_image_src( $image_id, $full_size ); $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); $output .= ''; } $output .= '
'; $output .= '
'; return $output; } } if ( ! function_exists( 'wpstream_theme_single_product_generate_fancybox' ) ) { /** * Generate HTML for a gallery using FancyBox. * * @param array $image_ids Array of attachment IDs for the images in the gallery. * @param string $full_size The size of the full-size images. * @return string Returns the HTML for the gallery. */ function wpstream_theme_single_product_generate_fancybox( $image_ids, $full_size = 'full' ) { $output = '
'; // Generate the first item $output .= wpstream_generate_fancybox_image_html( $image_ids[0], 'wpstream_featured_blog_image', count( $image_ids ) === 1 ? 'col-12' : 'col-12 col-sm-12 col-md-12 col-lg-9' ); // Generate the rest of the gallery images array_shift( $image_ids ); if ( ! empty( $image_ids ) ) { $output .= '
'; foreach ( $image_ids as $image_id ) { $output .= wpstream_generate_fancybox_image_html( $image_id, $full_size, 'col-6 col-sm-6 col-md-4 col-lg-3' ); } $output .= '
'; } $output .= '
'; return $output; } } if ( ! function_exists( 'wpstream_generate_fancybox_image_html') ) { function wpstream_generate_fancybox_image_html( $image_id, $full_size, $class ) { $wpstream_featured_unit_cards = wp_get_attachment_image_src( $image_id, $full_size ); $image_src = wp_get_attachment_image_src( $image_id, $full_size ); $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); if ( ! isset( $image_src[0] ) ) { return ''; } $output = ''; return $output; } }