You can use wp_get_attachment_image_src and get your desired sized image and then pass onto your array :
foreach( $posts as $post ) {
$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "medium" );
$imgsrc = $imgsrc[0];
$output[] = array(
'id' => $post->ID,
'title' => $post->post_title,
'count' => $post->custom_total_hits,
'soundcloud_url' => $post->soundcloud_song,
'soundcloud_id' => $post->soundcloud_ids,
'link' => get_permalink($post),
'image_src' => $imgsrc
);
}
echo json_encode($output);
Related Posts:
- WP_Query result in form of Rest API results
- Count the number of images uploded on the website
- How to paginate attachments in a secondary query as gallery?
- How do I exclude all images from a wp_query?
- WP Rest API v2 return posts with specific tag
- Get attachment by slug
- JSON: schedule creation of json file
- get images attached to post
- How to display images in related posts?
- Why use JSON API to display recent posts?
- post thumb nail
- query attachments of parent page if attachments of current page are smaller than …
- wp_query for displaying attachments with a tag
- WP Query search for attachments and their exact title
- How can I convert results of WP_Query (of Custom Post Type, with Custom Fields) to JavaScript?
- Querying A Post That Includes Two Taxonomies Using JSON Rest API
- How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 – 343)
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Better wordpress attachment query than this
- JSON – Create rest api endpoint for Advanced Custom Fields
- How to get more data of a post by wp_query
- How to add WordPress featured image via SQL
- Display all attached image of every post of custom post type and link to original post
- Insert images into wordpress post with a query
- Find only those galleries with images
- WP_Query: attachment image in “full” size?
- Change database image location for transportability
- Trying to use “Medium” featured image for custom post type on home page
- wp_get_attachment_image not to get the post_thumbnaill
- How To Query All Attachment Images Found In Post Galleries
- Display images with same specific value?
- Some images not being returned with wp_get_attachment_image
- Pull Instagram images into an existing loop?
- Custom Taxonomy in custom REST API search
- Simple Apex Charts with jQuery not working
- Order by multiple meta key and meta value [closed]
- Order by optional meta key?
- WP_query to get the first two latest posts, then another loop to get the next three
- Why is WP_Query not working with category_name?
- ‘Trying to get property of non-object’ when using WP_Query with ‘fields’ => ‘ids’
- Execute a large WP_Query with many “AND” Meta_Queries?
- RSS feed with specific keyword
- Get All IDs Of A Post Type Using WP_Query
- Group posts by custom field
- Multiple endpoints in one URL
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- how to fire join query with post_meta
- Show one post per author and limit query to 8 posts
- Get term by custom term meta and taxonomy
- SELECT * FROM $wpdb->posts WHERE ID > 160
- How to show the posts of some category first, and then all other
- Explanation of WP_Query
- Pagination stops at page 6
- Paginated HTML Sitemap
- How to limit total number of posts in wp query loop?
- How to get posts on a specific date – WP Query
- WP_Query no posts with tax_query
- WP_Query with Metavalue
- My Main Query Modification is Messing up my dynamic main – why?
- WP_Query meta_query >= date
- need to exclude APP_TAX_STORE => $term->slug
- Get a post from other loop each n-posts in the main loop
- Search for multiple tags?
- paging in WP_Query on static page
- WP_Query() and get_posts() can’t handle over a thousand posts?
- Query by multiple meta elements not seeming to work – wordpress is timing out
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Post loop for all taxonomy terms
- Problem with is_tax in WP_Query loop
- WP_Query and is_page_template() conditional
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Limit number of posts in loop
- Slow Query On Search
- Loop posts based on permalink term
- How to get current page nearest parent id?
- How to create Page templates for showing Blog posts in different layouts?
- wp Query Posts to display in Nivo Slider
- How to get only ONE category of “Portfolio” posts to display on main page rather than ALL categories?
- Determining what post is displayed out of total posts found
- Strange behaviour of hierarchical taxonomy archive
- Is it normal that get_post() gets run 300 times and the content of those posts aren’t visible?
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Get posts having meta value between two numbers
- WP_Query how to add a thumbnail to the first post from the last 5 posts?
- How order by works?
- taxquery taxonomy get terms
- Rewind posts then show only first post
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- why is this query returning entire blog-posts
- Pagination With Custom WP Query not functioning
- how do i remove plusone js from WP? [closed]
- Fatal error with wp-livechat plugin
- Filter posts by category
- Custom WordPress loop, articles not in same order as Array
- Group By query based on Custom Field