Hi again! Sorry for the delay; I’ve been out this weekend and couldn’t answer before. As it turns out, I have a copy of the Newspaper theme, and I could directly check the source code and see what you have to fix.
The first file you’ll have to edit to fix the featured image on the list of latest posts is includes/wp_booster/td_module.php
. On line 256, you’ll see the following statement:
$buffy .= '<img width="' . $td_temp_image_url[1] . '" height="' . $td_temp_image_url[2] . '" itemprop="image" class="entry-thumb" src="' . $td_temp_image_url[0] . '" ' . $attachment_a lt . $attachment_title . '/>';
“Replace” it with the following piece of code:
if ( function_exists( 'uses_nelioefi' ) && uses_nelioefi( $this->post->ID ) ) {
global $_wp_additional_image_sizes;
$nelio_width = $_wp_additional_image_sizes[$thumbType]['width'];
$nelio_height = $_wp_additional_image_sizes[$thumbType]['height'];
$buffy .= get_the_post_thumbnail(
$this->post->ID,
array( $nelio_width, $nelio_height ),
array( 'class' => 'entry-thumb' )
);
}
else {
$buffy .= '<img width="' . $td_temp_image_url[1] . '" height="' . $td_temp_image_url[2] . '" itemprop="image" class="entry-thumb" src="' . $td_temp_image_url[0] . '" ' . $attachment_a lt . $attachment_title . '/>';
}
Essentially, what this piece of code is doing is: if the post is using an external featured image, the img
tag you’ll have to use is the one returned by WordPress’ standard function get_the_post_thumbnail
. Otherwise, use theme’s regular approach (note that the original line wasn’t removed, but used in the else
block).
Then, in order to fix the featured image when viewing a concrete post, you’ll have to edit file includes/modules/module_modifier/td_module_blog.php
lines 213-236. We’ll do the same we did before: we’ll create a new if-else
block and surround the already-existing code from lines 213-236 into the else
part of the code we add. This is the code you need:
if ( function_exists( 'uses_nelioefi' ) && uses_nelioefi( $this->post->ID ) ) {
$buffy = '';
if ( is_single() ) {
$image_html = get_the_post_thumbnail(
$this->post->ID,
false,
array( 'class' => 'entry-thumb single-nelioefi' )
);
}
else {
$image_html = '<a href="' . $this->href . '">';
$image_html .= get_the_post_thumbnail(
$this->post->ID,
false,
array( 'class' => 'entry-thumb single-nelioefi' )
);
$image_html .= '</a>';
}
}
else {
// Here, the original code has to be placed. It starts with:
$featured_image_id = get_post_thumbnail_id($this->post->ID);
// And it goes on and on until:
$image_html = '<a href="' . $this->href . '"> [...] </a>';
}
// And right after the else block we just inserted, comes this:
$buffy .= '<div class="td-post-featured-image">';
This will insert the external featured image into your HTML code. However, the image won’t be visible. You’ll have to add a new CSS rule:
img.single-nelioefi {
width:100%;
height:300px;
}
You can tweak it as you please, and the featured image will look like the way you want it to look like.
I hope this solves your problems! There might be other issues with galleries and so on… But that requires too much of your/my time! I’d recommend you contact the theme developer and ask him to use the function (get_)the_post_thumbnail
for printing the img
tag for featured images wherever a featured image is needed. Also, please note that, whenever the theme is updated, all your changes will be lost.