Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/thumbnail.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");

// Change the upload subdirectory
define( 'BFITHUMB_UPLOAD_DIR', 'cache' );
define( 'MWP_BlankImage', MWP_PATH_URL . '/images/blank.jpg');
/* 
 * Disable wordpress generate default size
 *
*/
function remove_default_size () {
	update_option( 'thumbnail_size_h', 0 );
	update_option( 'thumbnail_size_w', 0 );
	update_option( 'medium_size_h', 0 );
	update_option( 'medium_size_w', 0 );
	update_option( 'large_size_h', 0 );
	update_option( 'large_size_w', 0 );
}
add_action("after_switch_theme", "remove_default_size", 10 , 2);

/*
 * Function Description	: Automatically Set the Featured Image in WordPress
 * Author Name			: Jonathan Dingman
 * Devlopped By			: Mouad Achemli (just add default thumbnail) :p
 * Function Source		: http://wpforce.com/automatically-set-the-featured-image-in-wordpress/
 * Note					: this function is important do not remove from here
 *
*/
function autoset_featured() {
	if (mwp_option('featured-thumbnail-autoset') == 1) :
		global $post;
		$get_default_thumbnail = mwp_option('thumbnail-default');
		if (!empty($get_default_thumbnail)) {
			$default_thumbnail = $get_default_thumbnail;
		} else {
			$default_thumbnail = get_template_directory_uri().'/images/no-thumbnail.jpg';
		}
		$postsetid = get_the_ID();
		$already_has_thumb = has_post_thumbnail($post->ID);
		
		if (!$already_has_thumb)  {
			$attached_image = get_children( 'post_type=attachment&post_mime_type=image&post_parent='.$postsetid );
			if ($attached_image) {
				foreach ($attached_image as $attachment_id => $attachment) {
					set_post_thumbnail($post->ID, $attachment_id);
				}
			} else {
				set_post_thumbnail($post->ID, attachment_url_to_postid($default_thumbnail));
			}
		}
	endif;
}
add_action('the_post', 'autoset_featured');

/*
 * Helper for Pinit Button
 * 
*/
function mwp_post_thumb_url() {
	global $post;
	$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
	$url = $thumb['0'];
	return $url;
}
/*
 * Get Thumbnail URL 
 *
 * Used in slider 7
 * 
*/
function mwp_get_thumb_url($postid, $width, $height, $size_name) {
	
	if (mwp_option('thumbnail-vyd') == 0 || has_post_thumbnail() ) {
		return mwp_thumb_size_src($width, $height, $size_name, $postid);
	} else {
		// New custom field Youtube & Vimeo & Dailymotion
		$key_exists_yt = metadata_exists( 'post', $postid, 'mwp_yt_id' );
		$key_exists_vi = metadata_exists( 'post', $postid, 'mwp_vi_thumbnail' );
		$key_exists_dm = metadata_exists( 'post', $postid, 'mwp_dm_thumbnail' );
		$key_exists_fb = metadata_exists( 'post', $postid, 'mwp_fb_id' );
		// Get New custom field value (Video ID)
		$check_y = get_post_meta($postid, 'mwp_yt_id' , true);
		$check_v = get_post_meta($postid, 'mwp_vi_thumbnail' , true);
		$check_d = get_post_meta($postid, 'mwp_dm_thumbnail' , true);
		$check_f = get_post_meta($postid, 'mwp_fb_id' , true);
		if ($key_exists_yt == true && !empty($check_y)) {
			return "https://i1.ytimg.com/vi/$check_y/hqdefault.jpg";
		} elseif ($key_exists_vi == true && !empty($check_v)) {
			return $check_v;
		} elseif ($key_exists_dm == true && !empty($check_d)) {
			return $check_d;
		} elseif ($key_exists_fb == true && !empty($check_f)) {
			return $check_f;
		} else {
			return mwp_thumb_size_src($width, $height, $size_name, $postid);
		}
	}
}
/*
 * Function Description	: Get attachment ID by Image URL
 * Author Name			: james lafferty
 * Function Source		: http://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url
 * Note					: this function is important do not remove from here
 *
*/
function get_attachment_id_from_src($image_src) {
	global $wpdb;
	return $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'");
}
/*
 * Function Description	: Get attachment ID by Image URL
 * Author Name			: james lafferty
 * Function Source		: http://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url
 * Note					: this function is important do not remove from here
 *
*/
function mwp_get_attachment_id_from_src( $attachment_url = '' ) {
	global $wpdb;
	$attachment_id = false;
	if ( '' == $attachment_url )
		return;
	$upload_dir_paths = wp_upload_dir();
	if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) {
		$attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url );
		$attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
		$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) );
	}
	return $attachment_id;
}

/*
 * Helper
 * Timthumb SEO url friendly 
 * Remove HTTP or HTTPS from image url
*/
function remove_http($url = '') {
	if ($url == 'http://' OR $url == 'https://'){
        return $url;
    }
	$matches = substr($url, 0, 7);
	if ($matches=='http://'){
		$url = substr($url, 7);
	} else {
        $matches = substr($url, 0, 8);
		if ($matches=='https://') 
		$url = substr($url, 8);
	}
    return $url;
}
/*	
 * Function Description	: Display image with custom field of post 
 * Author Name			: Mouad Achemli
 * Function Source		: https://www.mwordpress.net
 * Note					: this function is important do not remove from here
 *
*/
function image_post_resized($key, $width, $height, $class, $crop) {
	global $post;
	$title 			= get_the_title();
	$class_lazy 	= 'lazy img-responsive';
	$class_nolazy 	= 'img-responsive';
	$img_blank 		= MWP_BlankImage;
	
	if (strpos($class,'no-lazy') !== false || mwp_option('lazyload-mobile') == 0) {
		$class_print = $class_nolazy;
	} else {
		$class_print = $class_lazy;
	}
	
	$url = get_post_meta($post->ID, $key, true);
	if (!empty($url)) {
		$get_quality = mwp_option('thumbnail-quality');
		if (!empty($get_quality)) {
			$quality = $get_quality;	
		} else {
			$quality = 100;
		}
		$bfi_params = array(
			'width' 	=> $width,
			'height' 	=> $height,
			'crop' 		=> $crop,
			'quality'	=> $quality
		);
		$image 	= bfi_thumb( $url, $bfi_params );
		if (mwp_option('lazyload-mobile') == 0 || strpos($class,'no-lazy') !== false) {
			echo '<img class="'.$class_print.'" src="'.$image.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
		} elseif (mwp_option('lazyload-mobile') == 1) {
			echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$image.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			//echo '<noscript><img class="'.$class_print.'" src="'.$image.'" alt="'.$title.'" ></noscript>';
		}
	} else {
		mwp_thumb_size_default($class, $width, $height);
	}
}
/*	
 * Function Description	: GET IMAGE SRC with custom field
 * Author Name			: Mouad Achemli
 * Function Source		: https://www.mwordpress.net
 * Note					: this function is important do not remove from here
 *
*/
function image_post_resized_src($key) {
	global $post;
	$width 		= 772;
	$height 	= 432;
	$url = get_post_meta($post->ID, $key, true);
	if (!empty($url)) {
		$bfi_params = array( 
			'width' 	=> $width, 
			'height' 	=> $height, 
			'crop' 		=> false, 
			'quality' 	=> 100  
		);
		$image 	= bfi_thumb( $url, $bfi_params );
		return $image;	
	} else {
		mwp_thumb_size_default_src();
	}
}
/*
 * Function Description	: Get Images Attached to a Post
 * Author Name			: John Crenshaw
 * Devlopped By			: Mouad Achemli (just add default thumbnail) :p
 * Function Source		: http://www.rlmseo.com/blog/get-images-attached-to-post/
 * Note					: this function is important do not remove from here
 *
*/
function getImage() {
	$iPostID = get_the_ID();
    $arrImages = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $iPostID );

	if($arrImages) {
		$arrKeys = array_keys($arrImages);
        $iNum = $arrKeys[0];
        $sImageUrl = wp_get_attachment_url($iNum);
		$sImgString = $sImageUrl;
		return $sImgString;
	} elseif(empty($arrImages)){
		$get_default_thumbnail = mwp_option('thumbnail-default');
		if (!empty($get_default_thumbnail)) {
			$def_thumbnail = $get_default_thumbnail;
		} else {
			$def_thumbnail = get_template_directory_uri().'/images/no-thumbnail.jpg';
		}
		$sImgString = $def_thumbnail;
		return $sImgString;
	}
}
/*
 * Function Description	: Displays the first image of a post
 * Author Name			: Melissa
 * Devlopped By			: Mouad Achemli (just add default thumbnail) :p
 * Function Source		: http://www.mhsiung.com/2010/06/catch_that_image-fix/
 *						: http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it 
 *						: http://wordpress.org/support/topic/246893
 * Note					: this function is important do not remove from here
 *
*/
function getImage_external() {
	global $post, $posts;
	$first_img = '';
	ob_start();
	ob_end_clean();
	$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
	if (isset($matches[1][0])) {
		$first_img = $matches[1][0];
	} else {
		$get_default_thumbnail = mwp_option('thumbnail-default');
		if (!empty($get_default_thumbnail)) {
			$def_thumbnail = $get_default_thumbnail;
		} else {
			$def_thumbnail = get_template_directory_uri().'/images/no-thumbnail.jpg';
		}
		$first_img = $def_thumbnail;
	}
	return $first_img;
}

/*
 * Function Description	: Displays the first image of a post and resize (just intern images)
 * Author Name			: Melissa
 * Devlopped By			: Mouad Achemli
 * Note					: this function is important do not remove from here
 *
*/
function get_first_thumbnail() {
	global $post;
	ob_start();
	ob_end_clean();
	$post_img = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
	if (isset($matches[1][0])) {
		$url = $matches[1][0];
		return  $url;
	} else {
		$default_thumbnail = mwp_option('thumbnail-default');
		if (!empty($default_thumbnail)) {
			$url = $default_thumbnail;
		} else {
			$url = get_template_directory_uri().'/images/no-thumbnail.jpg';
		}
		return $url;
	}
}
/*!
 * Function Description	: Default Post Thumbnail (Helper)
 * Author Name			: Mouad Achemli
 * Function Source		: https://www.mwordpress.net
 * Note					: this function is important do not remove from here
 *
*/
function mwp_thumb_size_default($class, $width, $height) {
	
	$title 			= get_the_title();
	$class_lazy 	= $class . ' lazy';
	$class_nolazy 	= $class;
	$img_blank 		= MWP_BlankImage;
	
	if (strpos($class,'no-lazy') !== false || mwp_option('lazyload-mobile') == 0) {
		$class_print = $class_nolazy;
	} else {
		$class_print = $class_lazy;
	}
	
	$get_default = mwp_option('thumbnail-default');
	if (!empty($get_default)) {
		$thumbnail = $get_default;
	} else {
		$thumbnail = get_template_directory_uri().'/images/no-thumbnail.jpg';
	}
	$image 	= $thumbnail;

	if (mwp_option('lazyload-mobile') == 0 || strpos($class,'no-lazy') !== false) :
		echo '<img class="'.$class_print.'" src="'.$image.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
	elseif (mwp_option('lazyload-mobile') == 1 ) :	
		echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$image.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
	endif;
	
}
/*!
 * Function Description	: Default Post Thumbnail [ --> Image Source <-- ] (Helper)
 * Author Name			: Mouad Achemli
 * Function Source		: https://www.mwordpress.net
 * Note					: this function is important do not remove from here
 *
*/
function mwp_thumb_size_default_src() {
	$get_default_thumbnail = mwp_option('thumbnail-default');
	if (!empty($get_default_thumbnail)) {
		$def_thumbnail = $get_default_thumbnail;
	} else {
		$def_thumbnail = get_template_directory_uri().'/images/no-thumbnail.jpg';
	}
	$image 	= $def_thumbnail;
	return $image;
}
/*!
 * Function Description	: Custom Post Thumbnail 
 * Author Name			: Mouad Achemli
 * Function Source		: https://www.mwordpress.net
 * Note					: this function is important do not remove from here
 *
*/
function mwp_thumb_size($size, $width, $height, $class, $crop=false) {
	
	global $post;
	$title 			= get_the_title();
	$img_blank 		= MWP_BlankImage;	
	$thumbnail_type = mwp_option('thumbnail-type');
	$lazyload_check = mwp_option('lazyload-mobile');
	
	/*
	 * Lazyload Class
	 *
	*/
	$class_lazy 	= $class . ' lazy lazy-hidden';
	$class_nolazy 	= $class;
	if (strpos($class,'no-lazy') !== false || $lazyload_check == 0) {
		$class_print = $class_nolazy;
	} else {
		$class_print = $class_lazy;
	}

	/*
	 * Method 1 : BFI_thumb
	 *
	*/
	if ($thumbnail_type == 1) {
		$image_url = get_post_meta($post->ID, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			$get_quality = mwp_option('thumbnail-quality');
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			if ($crop == 'center') {
				$position = 'center';
			} elseif ($crop == true) {
				$position = true;
			} else {
				$position = false;
			}
			$bfi_params = array( 
				'width' 	=> $width, 
				'height' 	=> $height, 
				'crop' 		=> $position, 
				'quality' 	=> $quality
			);
			$image 	= bfi_thumb( $url, $bfi_params );
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'.$image.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$image.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'.$image.'" alt="'.$title.'" ></noscript>';
			}
		} else {
			mwp_thumb_size_default($class, $width, $height);
		}
	} 
	/*
	 * Method 2 : Custom Field
	 *
	*/
	if ($thumbnail_type == 2) {
		image_post_resized(mwp_option('custom-field-name'), $width, $height, $class, $position=false);
	} 
	/*
	 * Method 3 : First Image in attachments
	 *
	*/
	if ($thumbnail_type == 3) {
		$url = getImage('1');
		if (!empty($url)) {
			$get_quality = mwp_option('thumbnail-quality');
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			if ($crop == 'center') {
				$position = 'center';
			} elseif ($crop == true) {
				$position = true;
			} else {
				$position = false;
			}
			$bfi_params = array( 
				'width' 	=> $width, 
				'height' 	=> $height, 
				'crop' 		=> $position, 
				'quality' 	=> $quality
			);
			$image 	= bfi_thumb( $url, $bfi_params );
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'.$image.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$image.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'.$image.'" alt="'.$title.'" ></noscript>';
			}
		} else {
			mwp_thumb_size_default($class, $width, $height);
		}
	} 
	/*
	 * Method 4 : First Image in Post Content (Scal Only)
	 *
	*/
	if($thumbnail_type == 4) {
		?><img class="<?php echo $class; ?>"  alt="<?php the_title(); ?>" src="<?php echo getImage_external('1'); ?>" height="<?php echo $height; ?>" width="<?php echo $width; ?>" /><?php
	} 
	/*
	 * Method 5 : First Image in Post Content
	 *
	*/
	if(mwp_option('thumbnail-type') == 5) {
		$url 	= get_first_thumbnail();
		$image 	= parse_url($url, PHP_URL_HOST);
		$local 	= parse_url(get_bloginfo('url'), PHP_URL_HOST);
		if ($image == $local) {
			$get_quality = mwp_option('thumbnail-quality');
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			if ($crop == 'center') {
				$position = 'center';
			} elseif ($crop == true) {
				$position = true;
			} else {
				$position = false;
			}
			$bfi_params = array( 
				'width' 	=> $width, 
				'height' 	=> $height, 
				'crop' 		=> $position, 
				'quality' 	=> $quality
			);
			$image 	= bfi_thumb( $url, $bfi_params );
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'.$image.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$image.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'.$image.'" alt="'.$title.'" ></noscript>';
			}
		} else {
			mwp_thumb_size_default($class, $width, $height);
		}
	} 
	/*
	 * Method 6 : TimThumb
	 *
	*/
	if($thumbnail_type == 6) {
		$get_quality = mwp_option('thumbnail-quality');
		if (!empty($get_quality)) {
			$quality = $get_quality;	
		} else {
			$quality = 100;
		}
		if ($crop == 'center') {
			$position = 'zc=1&amp;a=t&amp;';
		} else {
			$position = 'zc=0&amp;';
		}
		$image_url = get_post_meta($post->ID, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'. get_template_directory_uri().'/resize.php?src='.$url.'&amp;w='.$width.'&amp;h='.$height.'&amp;'.$position.'q='.$quality.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'. get_template_directory_uri().'/resize.php?src='.$url.'&amp;w='.$width.'&amp;h='.$height.'&amp;'.$position.'q='.$quality.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'. get_template_directory_uri().'/resize.php?src='.$url.'&amp;w='.$width.'&amp;h='.$height.'&amp;'.$position.'q='.$quality.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" /></noscript>';
			}
		} else {
			mwp_thumb_size_default($class, $width, $height);
		}
	} 
	/*
	 * Method 7 : TimThumb SEO url friendly
	 *
	*/
	if($thumbnail_type == 7) {
		$image_url = get_post_meta($post->ID, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'. home_url().'/media/resizer/'.$width.'x'.$height.'/r/'.remove_http($url).'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'. home_url().'/media/resizer/'.$width.'x'.$height.'/r/'.remove_http($url).'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'. home_url().'/media/resizer/'.$width.'x'.$height.'/r/'.remove_http($url).'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" /></noscript>';
			}
		} else {
			mwp_thumb_size_default($class, $width, $height);
		}
	} 
	/*
	 * Method 8 : JetPack Photon
	 *
	*/
	if ($thumbnail_type == 8) {
		
		$image_url = get_post_meta($post->ID, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			$get_quality = mwp_option('thumbnail-quality');
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			if ($crop == 'center') {
				$param 	= array(
					'quality' 	=> $quality,
					'crop' 		=> '0,0,'.$width.','.$height
				);
			} else {
				$param 	= array(
					'resize' 	=> $width.','.$height,
					'quality' 	=> $quality,
					'strip' 	=> 'all',
				);
			}
			$image 	= jetpack_photon_url( $url, $param );
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'.$image.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$image.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'.$image.'" alt="'.$title.'" ></noscript>';
			}
		} else {
			mwp_thumb_size_default($class, $width, $height);
		}
	} 
	/*
	 * Method 9 : Wordpress Thumbnail
	 *
	*/
	if ($thumbnail_type == 9) {
		$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size );
		$url 	= $thumb['0'];
		if (!empty($url)) {	
			if ($lazyload_check == 0 || strpos($class,'no-lazy') !== false) {
				echo '<img class="'.$class_print.'" src="'.$url.'"  alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
			} else {
				echo '<img class="'.$class_print.'" src="'. $img_blank .'" data-src="'.$url.'" alt="'.$title.'" height="'.$height.'" width="'.$width.'" />';
				//echo '<noscript><img class="'.$class_print.'" src="'.$url.'" alt="'.$title.'" ></noscript>';
			}
		} else {	
			mwp_thumb_size_default($class, $width, $height);	
		}
	}
}
/*!
 * Function Description	: Custom Post Thumbnail 
 * Author Name			: Mouad Achemli
 * Function Source		: https://www.mwordpress.net
 * Note					: this function is important do not remove from here
 *
*/
function mwp_thumb_size_src($width, $height, $size=false, $postid=false) {
	
	global $post;
	if (!empty($postid)) {
		$post_id = $postid;
	} else {
		$post_id = $post->ID;
	}
	$thumbnail_type = mwp_option('thumbnail-type');
	
	/*
	 * Method 1 : BFI_thumb
	 *
	*/
	if ($thumbnail_type == 1) {
		$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);		
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			$get_quality = mwp_option('thumbnail-quality');	
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			$bfi_params = array(
				'width' 	=> $width, 
				'height' 	=> $height, 
				'crop' 		=> true, 
				'quality' 	=> $quality 
			);
			$image 	= bfi_thumb( $url, $bfi_params );
			return $image;
		} else {
			mwp_thumb_size_default_src();
		}
	} 
	/*
	 * Method 2 : Custom Field
	 *
	*/
	if ($thumbnail_type == 2) {
		$position = true;
		image_post_resized(mwp_option('custom-field-name'), $width, $height, $class, $position=false);
	} 
	/*
	 * Method 3 : First Image in attachments
	 *
	*/
	if ($thumbnail_type == 3) {
		$url = getImage('1');
		if (!empty($url)) {
			$get_quality = mwp_option('thumbnail-quality');	
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			$bfi_params = array(
				'width' 	=> $width, 
				'height' 	=> $height, 
				'crop' 		=> true, 
				'quality' 	=> $quality
			);
			$image 	= bfi_thumb( $url, $bfi_params );
			return $image;
		} else {
			mwp_thumb_size_default_src();
		}
	} 
	/*
	 * Method 4 : First Image in Post Content (Scal Only)
	 *
	*/
	if($thumbnail_type == 4) {
		return getImage_external('1');
	} 
	/*
	 * Method 5 : First Image in Post Content
	 *
	*/
	if($thumbnail_type == 5) {
		$url 	= get_first_thumbnail();
		$image 	= parse_url($url, PHP_URL_HOST);
		$local 	= parse_url(get_bloginfo('url'), PHP_URL_HOST);
		if ($image == $local) {
			$get_quality = mwp_option('thumbnail-quality');	
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			$bfi_params = array(
				'width' 	=> $width, 
				'height' 	=> $height, 
				'crop' 		=> true, 
				'quality' 	=> $quality
			);
			$image 	= bfi_thumb( $url, $bfi_params );
			return $image;
		} else {
			mwp_thumb_size_default_src();
		}
	}
	/*
	 * Method 6 : TimThumb
	 *
	*/
	if($thumbnail_type == 6) {
		$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			$position 		= 'zc=0&amp;';
			$get_quality 	= mwp_option('thumbnail-quality');	
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			$url = get_template_directory_uri().'/resize.php?src='.$url.'&amp;w='.$width.'&amp;h='.$height.'&amp;'.$position.'q='.$quality;
			return $url;
		} else {
			mwp_thumb_size_default_src();
		}
	} 
	/*
	 * Method 7 : TimThumb SEO url friendly
	 *
	*/
	if($thumbnail_type == 7) {
		$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			$url = home_url().'/media/resizer/'.$width.'x'.$height.'/r/'.remove_http($url);
			return $url;
		} else {
			mwp_thumb_size_default_src();
		}
	} 
	/*
	 * Method 8 : JetPack Photon
	 *
	*/
	if ($thumbnail_type == 8) {
		$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
		if(!empty($image_url)) {
			$url 	= $image_url;
		} else {
			$thumb 	= wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'full' );
			$url 	= $thumb['0'];
		};
		if (!empty($url)) {
			$get_quality 	= mwp_option('thumbnail-quality');	
			if (!empty($get_quality)) {
				$quality = $get_quality;	
			} else {
				$quality = 100;
			}
			$jetpack_param 	= array(
				'resize' 	=> $width.','.$height,
				'quality' 	=> $quality,
				'strip' 	=> 'all',
			);
			$image 	= jetpack_photon_url( $url, $jetpack_param );
			return $image;
		} else {	
			mwp_thumb_size_default_src();
		}
	}
	/*
	 * Method 9 : Wordpress Thumbnail
	 *
	*/
	if ($thumbnail_type == 9) {
		$thumbnail 	= wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size );
		$image 		= $thumbnail['0'];
		if (!empty($image)) {
			return $image;
		} else {		
			mwp_thumb_size_default_src();	
		}
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists