Visual Composer Get images from “attach_images”

In VC_MAP definition you have:

array(
	"type"        => "attach_images",
	"heading"     => esc_html__( "Screenshots", "text-domain" ),
	"description" => esc_html__( "Add screenshots.", "text-domain" ),
	"param_name"  => "screenshots",
	"value"       => "",
),

In shortcode function you should have:

$gallery = shortcode_atts(
	array(
		'screenshots'      =>  'screenshots',
	), $atts );

$image_ids=explode(',',$gallery['screenshots']);

$image_no = 1;
foreach( $image_ids as $image_id ){
	$images = wp_get_attachment_image_src( $image_id, 'full' );
	$output ='<img src="'. $images[0] .'" alt="" data-mce-src="'. $images[0] .'">';
	$image_no++;
}

return $output;

Leave a Reply