I am trying to display custom fileds created by me in visual composer by using custom short codes. This custom short codes run fine when i am working with heading and text area_html ,but now i want to add single image in this sort code,but in result i am not getting image,it displays alt attribute and in back-end side i am showing my single image that stores in custom shortcode field. here i am including my code.
1) code for creating custom shortcode
vc_map( array(
'name' => __( 'trionn_header' ),
'base' => 'trionn_header',
'category' => ( 'trionn code' ),
'params' => array(
"type" => "attach_image",
"holder" => "img",
"class" => "",
"heading" => __( "Hintergrundbild", "my-text-domain" ),
"param_name" => "image_url",
"value" => __( "", "my-text-domain" ),
"description" => __( lade eins hoch", "my-text-domain" )
)
) );
2) code in separate function-name file
<?php
/* Ordered List shortcode */
if (!function_exists('trionn_header')) {
function trionn_header($atts, $content) {
$atts = shortcode_atts(
array(
'image_url' => ''
), $atts, 'trionn_header'
);
$imageSrc = wp_get_attachment_image_src($image_url, 'thumbnail');
$html = '<img src="' . $imageSrc[0] .'" alt="' . $atts['title'] . '"/>';
return $html;
}
add_shortcode('trionn_header', 'trionn_header');
}