G’day everyone,
I wanna use Elementor to render images from a custom field (\_gallery) that my theme author made on CMB2 (ACF alternative I guess), but I wanna use a dynamic tag in order to get my images rendered by an Elementor widget such as the “gallery” one.
Here is how Elementor renders images for galleries with the “Post image attachments” dynamic tag :
public function get_value( array $options = [] ) {
$images = get_attached_media( ‘image’ );
$value = [];
foreach ( $images as $image ) {
$value[] = [
‘id’ => $image->ID,
];
}
return $value;
}
​
And here is the code used within my theme to render a gallery with images from the “\_gallery” custom field :
function slider_small_listing() {
global $post;
$gallery = get_post_meta( $post->ID, ‘_gallery’, true );
if(!empty($gallery)) :
echo ‘<div class=”listing-slider-small margin-bottom-0″>’;
$count = 0;
foreach ( (array) $gallery as $attachment_id => $attachment_url ) {
$image = wp_get_attachment_image_src( $attachment_id, ‘listeo-gallery’ );
$thumb = wp_get_attachment_image_src( $attachment_id, ‘thumbnail’ );
echo ‘<a href=”‘.esc_url($image[0]).'” data-background-image=”‘.esc_attr($image[0]).'” class=”item mfp-gallery”></a>’;
}
echo ‘</div>’;
endif;
}
How do I call the images from “\_gallery” and render them thru the dynamic tag ?
I’ve been trying for days with no luck… your help will be very appreciated.
