• Is it possible to have the Featured Image for each separate post displayed on the Blog (Post Summary) Page be the same as the image/photo used in the actual post which is from an external (URL) source?
    I’m using a content curation plugin that automatically populates new posts with the text and photo (where applicable) from the original online source and would like the same image displayed as the featured image next to the post summary as well as on the Recent Posts carousel.
    The plugin developer support team provided me with a php code to use but I have no idea how (where or if) the virtue theme calls images for the Blog/Post Summary Page (i.e. index.php, single.php, archive.php etc.).
    That stated, even if I were to identify where to apply the supplied code, as a novice ‘coder’, I would be unsure specifically where the code should be inserted (i.e. above or below existing, between specific tags etc.).
    The supplied code is as follows (*note – I have created a child theme as a backup):

    function UNIQUE_NAME_theme_thumbnail($pID,$thumb=’medium’) {
    $imgsrc = FALSE;
    if (has_post_thumbnail()) {
    $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($pID),$thumb);
    $imgsrc = $imgsrc[0];
    } elseif ($postimages = get_children(“post_parent=$pID&post_type=attachment&post_mime_type=image&numberposts=0”)) {
    foreach($postimages as $postimage) {
    $imgsrc = wp_get_attachment_image_src($postimage->ID, $thumb);
    $imgsrc = $imgsrc[0];
    }
    } elseif (preg_match(‘/<img [^>]*src=[“|\’]([^”|\’]+)/i’, get_the_content(), $match) != FALSE) {
    $imgsrc = $match[1];
    }
    if($imgsrc) {
    $imgsrc = ‘<img src=”‘.$imgsrc.'” alt=”‘.get_the_title().'” class=”summary-image” />‘;
    return $imgsrc;
    }
    }

Viewing 10 replies - 1 through 10 (of 10 total)
  • hannah

    (@hannahritner)

    Hey scorpion3367,
    Sorry, I’m a little confused. Is this not what happens by default? Like here- https://themes.kadencethemes.com/virtue/blog/
    Are you wanting something different? If so, could you link to an example?

    Hannah

    Thread Starter scorpion3367

    (@scorpion3367)

    Hi Hannah,
    Thanks for getting back to me on this. Unfortunately, the site that I’m currently working on is being hosted locally using MAMP so I can’t really provide any links. I could possibly take some screenshots but wouldn’t know where to post them.
    The short answer though is no. This is not what is happening by default.
    The link you included to the virtue blog is what I wish was happening, at least in terms of the layout (perhaps with the exception of the image sizes on the example page you provided).
    Maybe I haven’t got my settings correct?
    The images that are currently being displayed on the individual post pages are external (URL sourced from the original content).
    The content curation plugin I’m using inserts a ‘bookmarklet’ onto my browser’s (Chrome) Bookmarks Menu Bar.
    When I find relevant content I would like to add to the blog, I simply click the ‘curate’ bookmarklet which opens a new window where everything is formatted for automatic insertion as a new blog post including the text and the external image source. It allows for certain parameters to be tweaked but once I’m satisfied, it’s just a matter of clicking the ‘publish’ button for the new content to be posted into the blog.
    So then to confirm, I open the blog summary page which now lists a summarized version of the new post but does not display the photo (*note – my settings are configured to display the portrait image).
    Then when I click on the headline to open the post itself, the image is displayed there along with the story/article/text and a link to the website where the visitor has the option to read the entire content.
    So what I guess I’m trying to figure out, is how to have that same image/photo appear on the blog summary page from the same external source. In other words, without having to download the photo and then upload it to the media library and set it as the post’s featured image (which is the only way I am able to make it work at this juncture).
    What currently appears on my blog summary page to the left of an excerpt from the post is a 600 x 600 placeholder image (gray box with a pencil icon). Preferably, that placeholder would be populated with the same externally sourced image being used in the post.
    When I approached the plugin developers with this dilemma, I received the following response:
    “So what you are asking is more of how your theme handles images. It is possible to update your theme to do this but this requires coding and most likely editing your theme files.
    Here is the code (see original forum post) we use in our themes and in our own projects. Where your theme calls images in pages like index.php, single.php, archive.php, etc., you would put a call to this function. What it does is if there is a feature image it uses that. If there is no feature image then it uses the first found image in that post.

    Whew! I hope that all makes sense. I would be ever so grateful for any additional insight you might be able to offer. Hopefully it’s just something as simple as a few settings tweaks.
    I look forward to hearing back from you at your convenience.

    Hey,
    Thanks for the detailed explanation. I certainly understand ??

    The plugin authors are correct you would have to use a child theme but you can just add a function to the functions.php file

    You can get a child theme here: https://www.kadencethemes.com/child-themes/

    add this to the functions.php file in your child theme:

    function custom_theme_thumbnail($pID,$thumb='medium') {
    	$imgsrc = null;
    	if (has_post_thumbnail()) {
    		$imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($pID),$thumb);
    		$imgsrc = $imgsrc[0];
    	} elseif ($postimages = get_children("post_parent=$pID&post_type=attachment&post_mime_type=image&numberposts=0")) {
    		foreach($postimages as $postimage) {
    			$imgsrc = wp_get_attachment_image_src($postimage->ID, $thumb);
    			$imgsrc = $imgsrc[0];
    		}
    	} elseif (preg_match('/<img [^>]*src=["|\']([^"|\']+)/i', get_the_content(), $match) != FALSE) {
    		$imgsrc = $match[1];
    	}
    	if($imgsrc) {
    		return $imgsrc;
    	} else {
    		return null;
    	}
    }
    
    function custom_theme_post_default_placeholder_override() {
      global $post;
      $custom_image = custom_theme_thumbnail($post->ID);
      return $custom_image;
    }
    add_filter('kadence_post_default_placeholder_image', 'custom_theme_post_default_placeholder_override');
    add_filter('kadence_post_default_widget_placeholder_image', 'custom_theme_post_default_placeholder_override');

    Then just make sure you have set the default post summary to portrait image and on every post that you don’t have a set featured image this image will show.
    Kadence Themes

    Thread Starter scorpion3367

    (@scorpion3367)

    Thank you Kadence Support!
    Already had the child theme from the Kadence website in place (just in case).
    Added the code you suggested, closed the php tag (not sure if that was really necessary), saved the file, refreshed the page and bada-boom, bada-bing, success!
    Thank you for your time and effort in resolving this.

    Thread Starter scorpion3367

    (@scorpion3367)

    It appears as though I may have jumped the gun.
    While inserting the code you provided worked like a charm in displaying the external featured photo on the blog post summary page, when one scrolls further down the page and arrives at the recent posts carousel, the same issue is encountered (blank placeholders). In hindsight, I probably should have taken that into consideration as well.
    I guess I made an assumption (which was obviously wrong on my part and that’s on me) that this area would also have been populated in the same way by the same external featured image.
    Having said that however, is there an additional snippet of code that needs to be added or a slight code modification that would allow these images to appear in the Recent Posts Carousel as well?
    If so and once again, I would ever so appreciative if that could be suggested/provided and I apologize in advance for any inconvenience this lack of foresight on my part may have caused.
    Respectfully,
    scorpion3367

    Actually this is my issue. Your right in your assumption that should automatically affect those in the similar posts… I shall update the theme and fix this.

    Kadence Themes

    Thread Starter scorpion3367

    (@scorpion3367)

    Nice! I’m sure that’ll be a bonus ‘new feature’ to be able to promote as well.
    Any idea what sort of time frame you had in mind to complete this update so I have a rough idea as to when I can continue site development?

    Thread Starter scorpion3367

    (@scorpion3367)

    Just following up on your reply from two weeks ago to see whether this was an ongoing ‘work in progress’ or has perhaps inadvertently fallen by the wayside due to other more immediately pressing matters.
    I’m still experiencing the same issue and as a result, have had to manually upload the featured image to the Media Library in order for it to appear on the Post Summary Page.
    It’s interesting to note that the Featured Image appears just fine on the actual post based on an external URL but it’s still hit and miss (50/50 maybe?) that the same photo will appear on the Blog Post Summary Page.
    No pressure or anything but It’d sure be nice to get this resolved before my Media Library becomes a nightmare to navigate based on all the images I’m having to store there.
    If you need an example, I’m able to provide that now as I recently migrated the site in question from the local host to a live shared-hosting web server.

    Hey sorry for the delay. Are you using the latest version 2.6.7?

    Kadence Themes

    Thread Starter scorpion3367

    (@scorpion3367)

    Affirmative.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Blog (Post Summary) Page Display Featured Image from Post’ is closed to new replies.