I am trying to pass the wp_get_attachment_image_src call through this function
<?php
$url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); // Required
$width = 300; // Optional. Defaults to '150'
$height = 200; // Optional. Defaults to '150'
$crop = true; // Optional. Defaults to 'true'
$retina = false; // Optional. Defaults to 'false'
// Call the resizing function (returns an array)
$image = matthewruddy_image_resize( $url, $width, $height, $crop, $retina );
// Outputs resized image URL, http://yourwordpressdomain.com/wp-content/uploads/01/image1-300x200.png
echo $image['url']; ?>
The output does not render the image url but rather
<img src=" Array">
Please help! I've also tried to create a wordpress function based off of this code , with no luck either:
function tuts_custom_img( $thumb_size, $image_width, $image_height ) {
global $post;
$params = array( 'width' => $image_width, 'height' => $image_height );
$url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID, '' ), $thumb_size );
$custom_img_src = matthewruddy_image_resize( $url[0], $params );
return $custom_img_src;
}
From this $url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
you need to access the image source url as $url[0]
instead of $url
.
As here $url is an array.
Hope it works for you.
Instead of
<?php echo $image['url']; ?>
you can add this code.
<?php echo $url[0]; ?>