• Resolved cyberespia

    (@cyberespia)


    when I create an event and I don’t attach an image, the json for image return a boolean when should I return null .

    Here the correct code when the event have an image.

        {  
       "events":[  
          {  
             "id":4651,
             "title":"Test title",
             "description":"testttt",
             "image": {
                url: "https://myhost.tv/wp-content/uploads/2019/07/event2.jpg",
                id: "4652"}
           }
           ]
     }

    But when I create an event and I don’t attach any images the json is the following:

    {  
       "events":[  
          {  
             "id":4651,
             "title":"Stand Up Comedy",
             "description":"testttt",
             "image":false
           }
           ]
     }

    Return: “image”:false

    How could you solve this situation so that I return “null” and not “false”

Viewing 1 replies (of 1 total)
  • Thread Starter cyberespia

    (@cyberespia)

    At the moment I have made the change directly in the code, if someone has a better solution that does not interfere in the code for update updates please share it.

    Edit:
    plugins/the-events-calendar/src/Tribe/REST/V1/Post_Repository.php and change return false . to return null

    	protected function get_featured_image( $id ) {
    		$thumbnail_id = get_post_thumbnail_id( $id );
    
    		if ( empty( $thumbnail_id ) ) {
    			return null;
    		}
    .
    .
    .
Viewing 1 replies (of 1 total)
  • The topic ‘Imageless event returns a boolean in json’ is closed to new replies.