";
// LOAD ELEMENT
$elements = json_decode(urldecode($add_element));
// PAGINATION ### Change array for pagination ###
if($pagination_active == 'on') {
$pagination = get_query_var('fmg_page');
if(!isset($pagination) || empty($pagination)) { $pagination = 1; }
$images_array = array_chunk($elements,$pagination_number);
$pag = $pagination - 1;
$elements = $images_array[$pag];
$num_page_for_pagination = count($images_array); // VALUE FOR PAGINATION FUNCTION
}
// #PAGINATION
$counter = 1;
foreach ( $elements as $element ) {
$element_type = $element->element_type;
$element_caption_active = $element->element_caption_active;
$element_caption = '';
if($element_caption_active == 'on') {
$element_caption = $element->element_caption;
}
// CHECK CAPTION
$caption_check = '';
if($caption == 'off' || empty($element_caption)) {
$caption_check = 'no-caption';
}
// END CHECK CAPTION
if($element_type == 'image') { /* ELEMENT TYPE: IMAGE */
$image_lightbox = wp_get_attachment_image_src($element->element_type_image,$image_lightbox_size);
$url_lightbox = $image_lightbox[0];
$image_thumb = wp_get_attachment_image_src($element->element_type_image,$image_thumb_size);
$url_thumb = $image_thumb[0];
if($lazyload == 'on') {
$img_src = '
';
} else {
$img_src = '
';
}
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
} elseif($element_type == 'video') { /* ELEMENT TYPE: VIDEO */
wp_enqueue_script( 'fastmediagallery-lightgallery-js-vimeo');
$element_type_image_poster = $element->element_poster_image_type;
if($element_type_image_poster == 'custom') {
$poster = wp_get_attachment_image_src($element->element_image_poster,$image_lightbox_size);
$poster_url = $poster[0];
$poster_thumb = wp_get_attachment_image_src($element->element_image_poster,$image_thumb_size);
$poster_url_thumb = $poster_thumb[0];
} else {
$poster_url = $poster_url_thumb = VC_FMG_URL . 'assets/img/video_poster.jpg';
}
$url_type = $element->element_url_video_type;
if($lazyload == 'on') {
$img_src = '
';
} else {
$img_src = '
';
}
if($url_type == 'local') { // LOCAL
$url = $element->element_type_local_video;
$output_local .= '
';
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
} else { /* #LOCAL */
$url = $element->element_type_youtube_vimeo_video;
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
}
} elseif($element_type == 'audio') { /* ELEMENT TYPE: AUDIO */
$element_type_image_poster = $element->element_poster_image_type;
if($element_type_image_poster == 'custom') { // CUSTOM
$poster = wp_get_attachment_image_src($element->element_image_poster,$image_lightbox_size);
$poster_url = $poster[0];
$poster_thumb = wp_get_attachment_image_src($element->element_image_poster,$image_thumb_size);
$poster_url_thumb = $poster_thumb[0];
} else { // #CUSTOM
$poster_url = $poster_url_thumb = VC_FMG_URL . 'assets/img/audio_poster.jpg';
} // #DEFAULT
if($lazyload == 'on') {
$img_src = '
';
} else {
$img_src = '
';
}
$url_type = $element->element_url_audio_type;
if($url_type == 'local') { // LOCAL
$url = $element->element_type_local_audio;
$output_local .= '
';
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
} else { /* #LOCAL */
$url = $element->element_type_soundcloud_audio;
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
} /* #SOUNDCLOUD */
} elseif($element_type == 'iframe') { /* ELEMENT TYPE: IFRAME */
$url = $element->element_type_iframe;
$element_type_image_poster = $element->element_poster_image_type;
if($element_type_image_poster == 'custom') {
$poster_thumb = wp_get_attachment_image_src($element->element_image_poster,$image_thumb_size);
$poster_url_thumb = $poster_thumb[0];
} else {
$poster_url_thumb = VC_FMG_URL . 'assets/img/iframe_poster.jpg';
}
if($lazyload == 'on') {
$img_src = '
';
} else {
$img_src = '
';
}
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
} else { /* ELEMENT TYPE: IMAGE WITH CUSTOM URL */
$image_thumb = wp_get_attachment_image_src($element->element_type_image_custom_url,$image_thumb_size);
$url_thumb = $image_thumb[0];
$custom_url = $element->element_custom_url;
$custom_url_target = $element->element_custom_url_target;
if($lazyload == 'on') {
$img_src = '
';
} else {
$img_src = '
';
}
$output .= '
'.$img_src.'
';
if ($caption == 'on' && !empty($element_caption)) {
$output .= '
';
}
$output .= '
';
}
$counter++;
} // END FOREACH
$output .= "
";
if($pagination_active == 'on') {
$output .= '';
}
$output = $output_local . $output;
return $output;
}
}
new fastmediagallery_function();
/***************************************************
#### Function: fmg_enqueue_css_and_javascript() ####
#### Since: version 1.0 ############################
***************************************************/
function fmg_enqueue_css_and_javascript($type,$layout,$responsive_type,$lazyload,$active_custom_responsive,$fg_animate) {
// LOAD GENERAL CSS AND JAVASCRIPT
wp_enqueue_script('fastmediagallery-frontend-script');
wp_enqueue_style('fonts-vc');
// CUSTOM RESPONSIVE: LOAD CSS
if($active_custom_responsive == 'active_custom_responsive') {
wp_enqueue_style( 'fastmediagallery-custom-responsive-vc' );
}
// MASONRY: LOAD JAVASCRIPT
if($layout == 'fmg-masonry') {
wp_enqueue_script('jquery-masonry');
}
// LIGHTGALLERY: LOAD CSS AND JAVASCRIPT
if($type == 'lightgallery') {
wp_enqueue_style( 'fastmediagallery-lightgallery' );
wp_enqueue_script( 'fastmediagallery-lightgallery-js');
}
if($fg_animate == 'on') {
wp_enqueue_style( 'fastmediagallery-animations' );
wp_enqueue_script( 'fastmediagallery-appear-js');
wp_enqueue_script( 'fastmediagallery-animate-js');
}
if($lazyload == 'on') {
wp_enqueue_script( 'fastmediagallery-lazyload-js');
wp_enqueue_script( 'fastmediagallery-imagesLoaded-js');
}
}
/***************************************************
#### Function: fmg_thumbnails() ####################
#### Since: version 1.0 ############################
***************************************************/
function fmg_thumbnails() {
add_image_size( 'fmg-default-thumb', 1000, 800, true );
add_image_size( 'fmg-default-thumb-masonry', 800 );
add_image_size( 'fmg-default-lightbox', 1200, 1000, true );
}
add_action( 'init', 'fmg_thumbnails' );
/***************************************************
#### Function: fastmediagallery_vc_hex2rgb() #######
#### Since: version 1.0 ############################
***************************************************/
function fastmediagallery_vc_hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
$rgb = array($r, $g, $b);
return $rgb;
}
/***************************************************
#### Function: fmg_add_query_vars_pagination() #####
#### Since: version 1.0 ############################
***************************************************/
function fmg_add_query_vars_pagination( $vars ){
$vars[] = "fmg_page";
return $vars;
}
add_filter( 'query_vars', 'fmg_add_query_vars_pagination' );
/***************************************************
#### Function: get_fmg_pagination() ################
#### Since: version 1.0 ############################
***************************************************/
function get_fmg_pagination($num_page_for_pagination,$pagination) {
$output = '';
return $output;
}
/***************************************************
#### Function: fmg_style() #########################
#### Since: version 1.0 ############################
***************************************************/
function fmg_style($selector,
$main_color,
$main_color_opacity,
$secondary_color,
$spacing_active,
$spacing,
$name_show,
$gallery_name_font_size,
$gallery_name_font_color,
$gallery_name_text_align,
$pagination_active,
$pagination_style,
$image_width) {
// CHECK MAIN COLOR
$rgb_main_color = fastmediagallery_vc_hex2rgb($main_color);
$rgba_main_color = "rgba( ".$rgb_main_color[0]." , ".$rgb_main_color[1]." , ".$rgb_main_color[2]." , ".$main_color_opacity.")";
$rgb_secondary_color = fastmediagallery_vc_hex2rgb($secondary_color);
$rgba_secondary_color = "rgba( ".$rgb_secondary_color[0]." , ".$rgb_secondary_color[1]." , ".$rgb_secondary_color[2]." , 0.3)";
// END MAIN COLOR
$output = "
';
return $output;
}
?>