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
- How to make WP_Query ‘post__in’ accept an array?
- WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given
- Merging multiple wp_query objects
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Using custom meta_query with relation not working as expected
- Nested query inside Logical operator OR not working in meta_query
- SQL Statement generated by WP_Query not producing expected results
- Only show first post to match certain criteria within WP_Query
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- difference between $wp_the_query and $wp_query? & getting the values properly [duplicate]
- Custom Field sort not working (WP 3.8.1)
- Get post ID’s from one query and exclude from another
- What are the differences between “Latest Posts” and “Static Page”?
- WordPress Query is taking more then 20 second and stuck on creating index
- Modifying raw $_POST data early in the lifecycle
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Difficulty with rewrite rules
- Show selected images on top in Media Manager
- Complex date range with WP_Query and BETWEEN
- showing all search result in one template
- WP Query Args – Title or Taxonomy Value
- Ajax WP_Query reutrns no results on author.php
- Large AND OR query timing out
- WP_query wp_posts_counts returns only count of admin and not users
- Categorising search results based on Custom Fields
- How to query for all posts that have a particular meta key?
- Custom taxonomy.php not working
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- WP_Query calls all posts?
- WP_Query Taxonomy categories filtering
- The best way to store variable across different widgets
- Assign a minimum result count for WooCommerce query shortcodes?
- WPQuery calling specific posts problem
- Retrieve data from wordpress db via input and put those result in dropdown
- Filtering by multiple conditions in the loop
- Limit loop to future events
- How to access $wp_query object from array of posts given by get_posts?
- Custom wp_query differs on index page and category page
- WordPress Queries Not Working?
- Links in the_content not linked
- how do I write this wp_query select statement?
- How to make a post with certain taxonomy term display first before other post with only one query?
- Exception for excluding previously displayed posts in queries
- Post incorrectly excluded when using “category__in”?
- How do I compare the value of two taxonomies in a wp_query
- query hook parse_tax_query function takes no effect
- Categories In English version showing not canonical URL, instead shows query search result
- Related posts queries
- Check for not NULL not working in meta query
- Pagination for Category does not work
- Query against multiple locations within single custom post type post
- ACF query-pass field value
- How to make a search query if not found in post table then search in postmeta table?
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- Getting the last X posts, but in ascending order of time
- Show more than one post on the main page excluding certain category
- How to make a wordpress loop file that displays posts based on certain conditions
- WP_Query with MetaQuery issue
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Comment count same for every post in homepage WP_Query
- How do I display posts with specific value in a custom field into my loop?
- Order by multiple meta keys on wordpress
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen