function generate_art_image($i) {
$art_ID = '';
if($this->wdgt_config['data_source_type'] == 'post') {
$art_ID = $this->wdgt_results[$i][0]->ID;
} else {
$art_ID = $this->wdgt_results[$i]->ID;
}
$art_url = get_permalink($art_ID);
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $art_ID ), 'single-post-thumbnail' );
$image_path = $image[0];
$real_image_path = stripos($image_path, 'wp-content/uploads/');
$image_path = substr($image_path, $real_image_path);
$image_path = str_replace('wp-content/uploads/', '/uploads/', $image_path);
if($image_path != '') {
$new_path = image_resize(WP_CONTENT_DIR . $image_path, $this->wdgt_config['article_image_w'], $this->wdgt_config['article_image_h'], true, $this->id, dirname(__FILE__) . '/cache_nsp' );
if(is_string($new_path)) {
$new_path_pos = stripos($new_path, '/gavern/cache_nsp');
$new_path = substr($new_path, $new_path_pos);
$new_path = get_template_directory_uri() . $new_path;
$style = '';
if($this->wdgt_config['image_block_padding'] != '' && $this->wdgt_config['image_block_padding'] != '0') {
$style = ' style="margin: '.$this->wdgt_config['image_block_padding'].';"';
}
if($this->wdgt_config['article_image_pos'] == 'left' && $this->wdgt_config['article_image_order'] == 1) {
return '<div class="gk-nsp-image-wrap"><a href="'.$art_url.'" class="gk-image-link"><img src="'.$new_path.'" alt="" class="gk-nsp-image" '.$style.' /></a></div>';
} else {
return '<a href="'.$art_url.'" class="gk-responsive gk-image-link"><img src="'.$new_path.'" alt="" class="gk-nsp-image gk-responsive" '.$style.' /></a>';
}
} else {
return '<strong>Warning!</strong> Permissions for the gavern/cache_nsp directory are wrong or the PHP GD library is not installed and the thumbnails cannot be created.';
}
} else {
return '';
}
}
return '<strong>Warning!</strong> Permissions for the gavern/cache_nsp directory are wrong or the PHP GD library is not installed and the thumbnails cannot be created.';
return print_r($new_path->get_error_messages(), true);