سلام
این اسکریپت bfi thumbs هست گه برای کراپ در انداره وارد شده عمل میکنه
کلا برای کراپ کردن دو راه بیشتر وجود نداره که یکی اسکریپت بالاست و یکی توابع وردپرس
من خودم ار توابع استاندارد وردپرسدر تم هام استفاده میکنم و راحت تر میشه سایز ها رو تغییر داد
شما در تنظیمات پوستتون میتونید این اسکریپت را غیرفعال کنید
من کراپ را در کد هایی که ارسال کردید غیرفعال کردم
//////////////////////////////////////////////////////////////////
// Resizer
//////////////////////////////////////////////////////////////////
@define('BFITHUMB_UPLOAD_FOLDER', 'thumbs_dir');
require_once('inc/BFI_Thumb.php');
//////////////////////////////////////////////////////////////////
// Resizer function
//////////////////////////////////////////////////////////////////
if( !class_exists('WPSM_image_resizer') ) {
class WPSM_image_resizer{
public $src = '';
public $width = '';
public $height = '';
public $size = 'full';
public $crop = false;
public $lazy = false;
public $title = '';
public $use_thumb = false;
public $no_thumb = '';
public $quality = '100';
function __construct(){ //Enable lazy load when we need
if (rehub_option('enable_lazy_images') == '1'){
$this->lazy = true;
}
}
public function get_resized_url() { //Show resized url with bfi_thumb function
$params = array( 'width' => $this->width, 'height' => $this->height, 'quality' => $this->quality, 'crop' => false);
$image_url = esc_url($this->src);
if (empty ($this->src) && $this->use_thumb == true) {
$image_url = $this->get_mypost_thumb_url();
if(!rehub_option('rh_image_resize')){
$image_url = bfi_thumb( $image_url, $params );
}
$image_url = apply_filters('rh_thumb_resized_url', $image_url );
}
else {
if(!rehub_option('rh_image_resize')){
$image_url = bfi_thumb( $image_url, $params );
}
$image_url = apply_filters('rh_src_resized_url', $image_url );
}
if (empty($image_url)) {
$image_url = $this->no_thumb();
}
return $image_url;
}
public function get_not_resized_url(){ //Show not resized url of image
$image_url = esc_url($this->src);
if (empty ($this->src) && $this->use_thumb == true) {
$image_url = $this->get_mypost_thumb_url();
}
if (empty($image_url)) {
$image_url = $this->no_thumb();
}
return apply_filters('rh_thumb_notresized_url', $image_url );
}
public function get_mypost_thumb_url() {
global $post ;
$image_url = '';
if (function_exists('_nelioefi_url')){
$image_nelio_url = get_post_meta( $post->ID, _nelioefi_url(), true );
if (!empty($image_nelio_url)){
return apply_filters('rh_thumb_url', $image_nelio_url );
}
}
if ( has_post_thumbnail($post->ID) ){
$image_id = get_post_thumbnail_id($post->ID);
$image_url = wp_get_attachment_image_src($image_id, $this->size);
$image_url = (!empty($image_url)) ? $image_url[0] : '';
return apply_filters('rh_thumb_url', $image_url );
}
return apply_filters('rh_thumb_url', $image_url );
}
public static function get_post_thumb_static($size = 'full'){
global $post ;
$image_url = '';
if (function_exists('_nelioefi_url')){
$image_nelio_url = get_post_meta( $post->ID, _nelioefi_url(), true );
if (!empty($image_nelio_url)){
return apply_filters('rh_thumb_url', $image_nelio_url );
}
}
if ( has_post_thumbnail($post->ID) ){
$image_id = get_post_thumbnail_id($post->ID);
$image_url = wp_get_attachment_image_src($image_id,$size);
$image_url = (!empty($image_url)) ? $image_url[0] : '';
return apply_filters('rh_thumb_url', $image_url );
}
return apply_filters('rh_thumb_url', $image_url );
}
public function no_thumb(){ //Set blank image when no image url found
if(rehub_option('featured_fallback_img')){$image_url = esc_url(rehub_option('featured_fallback_img'));}
else if(!empty($this->no_thumb)){$image_url = $this->no_thumb;}
else {$image_url = get_template_directory_uri() . '/images/default/blank.gif';}
return apply_filters('rh_no_thumb_url', $image_url);
}
public function show_resized_image() {
$width_param = (!empty($this->width)) ? ' width="'.$this->width.'"': '';
$height_param = (!empty($this->height)) ? ' height="'.$this->height.'"': '';
$alt = (!empty($this->title)) ? $this->title : the_title_attribute (array('echo' => 0) );
if ($this->lazy == true){
if(function_exists('is_amp_endpoint') && is_amp_endpoint()){
echo '<img class="lazyload" data-skip-lazy="" data-src="'.$this->get_resized_url().'"'.$width_param.$height_param.' alt="'.wp_strip_all_tags($alt).'" src="'.$this->get_resized_url().'" />';
}else{
echo '<img class="lazyload" data-skip-lazy="" data-src="'.$this->get_resized_url().'"'.$width_param.$height_param.' alt="'.wp_strip_all_tags($alt).'" src="'.$this->no_thumb().'" />';
}
}
else {
echo '<img src="'.$this->get_resized_url().'"'.$width_param.$height_param.' alt="'.wp_strip_all_tags($alt).'" />';
}
}
public function show_not_resized_image() {
$width_param = (!empty($this->width)) ? ' width="'.$this->width.'"': '';
$height_param = (!empty($this->height)) ? ' height="'.$this->height.'"': '';
$alt = (!empty($this->title)) ? $this->title : the_title_attribute (array('echo' => 0) );
if ($this->lazy == true){
if(function_exists('is_amp_endpoint') && is_amp_endpoint()){
echo '<img class="lazyload" data-skip-lazy="" data-src="'.$this->get_not_resized_url().'"'.$width_param.$height_param.' alt="'.wp_strip_all_tags($alt).'" src="'.$this->get_not_resized_url().'" />';
}else{
echo '<img class="lazyload" data-skip-lazy="" data-src="'.$this->get_not_resized_url().'"'.$width_param.$height_param.' alt="'.wp_strip_all_tags($alt).'" src="'.$this->no_thumb().'" />';
}
}
else {
echo '<img src="'.$this->get_not_resized_url().'"'.$width_param.$height_param.' alt="'.wp_strip_all_tags($alt).'" />';
}
}
public static function show_static_resized_image($params = array()) {
$src = $width = $height = $title = $no_thumb_url = $no_thumb_fallback = '';
$crop = $lazy = $thumb = false;
if (rehub_option('enable_lazy_images') == '1'){
$lazy = true;
}
@extract ($params);
$params = array( 'width' => $width, 'height' => $height, 'crop' => false);
$no_thumb = (!empty($no_thumb_url)) ? apply_filters('rh_no_thumb_url', $no_thumb_url) : get_template_directory_uri() . '/images/default/blank.gif';
$image_url = esc_url($src);
if (empty($title)) {
$title = the_title_attribute (array('echo' => 0) );
}
if (!empty($image_url)) {
if(!rehub_option('rh_image_resize')){
$image_url = bfi_thumb( $image_url, $params );
}
$image_url = apply_filters('rh_static_resized_url', $image_url);
}
elseif (empty($image_url) && $thumb == true) {
$image_url = self::get_post_thumb_static();
if(!rehub_option('rh_image_resize')){
$image_url = bfi_thumb( $image_url, $params );
}
$image_url = apply_filters('rh_thumb_resized_url', $image_url );
}
if (empty($image_url)) {
if (!empty($no_thumb_fallback)) return $no_thumb_fallback;
$image_url = $no_thumb;
$image_url = apply_filters('rh_no_thumb_url', $image_url);
}
$width_param = (!empty($width)) ? ' width="'.$width.'"': '';
$height_param = (!empty($height)) ? ' height="'.$height.'"': '';
if ($lazy == true){
if(function_exists('is_amp_endpoint') && is_amp_endpoint()){
echo '<img class="lazyload" data-skip-lazy="" data-src="'.$image_url.'"'.$width_param.$height_param.' alt="'.esc_html($title).'" src="'.$image_url.'" />';
}else{
echo '<img class="lazyload" data-skip-lazy="" data-src="'.$image_url.'"'.$width_param.$height_param.' alt="'.esc_html($title).'" src="'.$no_thumb.'" />';
}
}
else {
echo '<img class="nolazyftheme" src="'.$image_url.'"'.$width_param.$height_param.' alt="'.$title.'" />';
}
}
public static function show_wp_image($image_size='full', $attachment_id = '', $attributes = array()) {
global $post;
$lazy = true;
$lazy = apply_filters('rh_lazy_load', $lazy, $attachment_id);
if (!rehub_option('enable_lazy_images') || !empty($attributes['lazydisable'])){
$lazy = false;
}
if(rehub_option('rh_image_resize')){
$image_size='full';
}
if(!empty($attributes['emptyimage'])){
$transparent = esc_url($attributes['emptyimage']);
}else{
$transparent = get_template_directory_uri() . '/images/default/blank.gif';
}
$image_id = ($attachment_id) ? (int)$attachment_id : get_post_thumbnail_id($post->ID);
$image = wp_get_attachment_image_src($image_id,$image_size);
$image_url = (!empty($image[0])) ? $image[0] : '';
$image_url = apply_filters('rh_thumb_url', $image_url );
$css_class = (!empty($attributes['css_class'])) ? $attributes['css_class'] : '';
$nofeatured = (!empty($attributes['nofeatured'])) ? true : false;
$imagewidth = (!empty($image[1])) ? esc_attr( $image[1] ) : '';
$imageheight = (!empty($image[2])) ? esc_attr( $image[2] ) : '';
if($imagewidth == 1) $imagewidth = '';
$output = '';
if ($lazy == true){
$alt = trim( strip_tags( get_post_meta($image_id, '_wp_attachment_image_alt', true ) ) );
$alt = apply_filters('wp_get_attachment_alt_attribute', $alt);
if (empty($alt)) {
$alt = the_title_attribute (array('echo' => 0) );
}
if ( $nofeatured || has_post_thumbnail($post->ID)){
if ( !empty($attributes )) {
if(!empty($attributes['max_height'])){
$attrmaxheight = esc_attr( $attributes['max_height'] );
$max_height = ' style="max-height:'.$attrmaxheight.';width:auto;"';
}else{
$max_height = '';
}
$data_large_image = '';
if (isset($attributes['data-large_image']))
{
$fullimage = wp_get_attachment_image_src($image_id, 'full' );
if(!empty($fullimage)){
$fullimage = $fullimage[0];
$data_large_image =' data-large_image="'.esc_attr($fullimage).'"';
}
}
$data_l_image_width = isset($attributes['data-large_image_width']) ? ' data-large_image_width="'.esc_attr( $attributes['data-large_image_width'] ).'"' : '';
$data_l_image_height = isset($attributes['data-large_image_height']) ? ' data-large_image_height="'.esc_attr( $attributes['data-large_image_height'] ).'"' : '';
$output = sprintf(
'<img src="%s" data-src="%s" alt="%s" data-skip-lazy="" class="lazyload %s"%s%s%s%s width="%s" height="%s">',
esc_url( $transparent ),
esc_url( $image_url ),
esc_attr( $alt ),
esc_attr( $css_class ),
$data_large_image,
$data_l_image_width,
$data_l_image_height,
$max_height,
$imagewidth,
$imageheight
);
} else {
$output = sprintf(
'<img src="%s" data-src="%s" alt="%s" data-skip-lazy="" class="lazyload %s" width="%s" height="%s">',
esc_url( $transparent ),
esc_url( $image_url ),
esc_attr( $alt ),
esc_attr( $css_class ),
$imagewidth,
$imageheight
);
}
}else{
if(rehub_option('featured_fallback_img')){
$nothumb_url = rehub_option('featured_fallback_img');
}
else if(!empty($attributes['no_thumb'])){
$nothumb_url = $attributes['no_thumb'];
}
else {
$nothumb_url = get_template_directory_uri() . '/images/default/noimage_500_500.png';
}
$nothumb_url = apply_filters('rh_no_thumb_url', $nothumb_url);
$output = sprintf(
'<img src="%s" data-src="%s" alt="%s" data-skip-lazy="" class="lazyload %s" width="%s" height="%s">',
esc_url( $transparent ),
esc_url( $nothumb_url),
esc_attr( $alt ),
esc_attr( $css_class ),
$imagewidth,
$imageheight
);
}
} else {
$attributes['class'] = $css_class;
if ( has_post_thumbnail($post->ID) ){
$output = wp_get_attachment_image( $image_id, $image_size, false, $attributes );
}else{
if(rehub_option('featured_fallback_img')){
$nothumb_url = rehub_option('featured_fallback_img');
}
else if(!empty($attributes['no_thumb'])){
$nothumb_url = $attributes['no_thumb'];
}
else {
$nothumb_url = get_template_directory_uri() . '/images/default/noimage_500_500.png';
}
$nothumb_url = apply_filters('rh_no_thumb_url', $nothumb_url);
$alt = the_title_attribute (array('echo' => 0) );
$output = sprintf(
'<img src="%s" alt="%s" class="%s">',
esc_url( $nothumb_url),
esc_attr( $alt ),
esc_attr( $css_class )
);
}
}
$output = apply_filters('rh_thumb_output', $output, $image_size);
return $output;
}
}}
//////////////////////////////////////////////////////////////////
// Thumbnail function
//////////////////////////////////////////////////////////////////
if( !function_exists('wpsm_thumb') ) {
function wpsm_thumb( $size = 'smallgrid', $maxheight='', $id=''){
$attributes = array();
if($maxheight && is_numeric($maxheight)){
$attributes['max_height'] = (int)$maxheight.'px';
}
if($size == 'smallgrid'){
$attributes['emptyimage'] = get_template_directory_uri() . '/images/default/noimage_220_150.png';
$attributes['no_thumb'] = get_template_directory_uri() . '/images/default/noimage_220_150.png';
}
elseif($size == 'mediumgrid'){
$attributes['emptyimage'] = get_template_directory_uri() . '/images/default/noimage_336_220.png';
$attributes['no_thumb'] = get_template_directory_uri() . '/images/default/noimage_336_220.png';
}
elseif($size == 'large_inner'){
$attributes['emptyimage'] = get_template_directory_uri() . '/images/default/noimage_450_350.png';
$attributes['no_thumb'] = get_template_directory_uri() . '/images/default/noimage_450_350.png';
}
elseif($size == 'minithumb'){
$attributes['emptyimage'] = get_template_directory_uri() . '/images/default/noimage_100_70.png';
$attributes['no_thumb'] = get_template_directory_uri() . '/images/default/noimage_100_70.png';
}
echo WPSM_image_resizer::show_wp_image($size, $id, $attributes);
}
}
//Siteground fix for lazy load
add_filter( 'sgo_lazy_load_exclude_classes', 'exclude_images_with_specific_class' );
function exclude_images_with_specific_class( $classes ) {
// Add the class name that you want to exclude from lazy load.
$classes[] = 'lazyload';
return $classes;
}