The following code is good for obtaining the post URL and title:
global $post;
$args = array( 'posts_per_page' => 5, 'offset'=> 1, 'category' => 4 );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <br />
<?php
endforeach;
wp_reset_postdata();
However what I need is to obtain the text/url of the featured image including the path but not print it to the screen. The purpose of doing this is so that I can create a custom-sized image using ImageMagick convert and display that to the screen not the original image.
I'll be doing something like
convert "$image" -resized (my custom size) -strip 400x/$image
The convert code is a little more complicated as I intend to create large square thumbs, but that is the goal. I will then be posting the images in a wall style gallery of square thumbs on a page along with links to the individual posts.
Is there anything like the_featured_image() that will get me the image which I can then set as a variable and run the convert code?
You can use get_the_post_thumbnail_url
to get URL of featured image or false if there is none. So inside your foreach
loop
$thumb_url = get_the_post_thumbnail_url(get_the_ID(), 'full'); //can also be $post->ID
if($thumb_url)
{
//do your stuff
}