Created
          February 13, 2018 18:36 
        
      - 
      
- 
        Save chrismcintosh/f3c37fd00ab31e827cf8d8d375af4318 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | add_filter('rest_prepare_post','add_featured_to_post_rest', 10, 3); | |
| function add_featured_to_post_rest($data, $post, $request) { | |
| $_data = $data->data; | |
| $thumbnail_id = get_post_thumbnail_id($post->ID); | |
| $thumbnail = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail'); | |
| $thumbnailMedium = wp_get_attachment_image_src( $thumbnail_id, 'medium'); | |
| $thumbnailLarge = wp_get_attachment_image_src( $thumbnail_id, 'large'); | |
| $thumbnailFull = wp_get_attachment_image_src( $thumbnail_id, 'full'); | |
| $_data['featured_thumb_src'] = $thumbnail[0]; | |
| $_data['featured_medium_src'] = $thumbnailMedium[0]; | |
| $_data['featured_large_src'] = $thumbnailLarge[0]; | |
| $_data['featured_full_src'] = $thumbnailFull[0]; | |
| $data->data = $_data; | |
| return $data; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment