• Resolved jormarques

    (@jormarques)


    Hi,
    I recently started working with the GD REST API to create data from my mobile app, I noticed the images are not working properly when creating posts from the API. via the regular API psot request you can upload a featured_media, but GD seems to have also the featured_image/images which by default will be image 0 and the featured one in the cards (Archive templates).

    The GD API documentation is very limited, no reference at all in how to add media/images to the listings, which takes the purpose of API, since Images are one of the most important aspects of a listing.

    This is the response I get when using API, which is not correct, as you can see id:0 for featured_image and image.

    "featured_media": 1551,
    "featured_image": {
    "id": 0,
    "title": "website screenshot",
    "src": "https://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.austintheatre.org%2F?w=825&h=430",
    "thumbnail": "https://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.austintheatre.org%2F?w=825&h=430",
    "width": "",
    "height": ""
    },
    "images": [
    {
    "id": 0,
    "title": "website screenshot",
    "src": "https://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.austintheatre.org%2F?w=825&h=430",
    "thumbnail": "https://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.austintheatre.org%2F?w=825&h=430",
    "featured": false,
    "position": 0
    }

    When I add media to GD in the POST request to create listing:

    "featured_media": 1546,
    "featured_image": [
    ],
    "images": [
    ],

    How can I add the featured_image and images in the POST request in order to have images in GD archives (item) cards.

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support alexrollin

    (@alexrollin)

    Hello,

    the images you posted about are fallback images and are part of the larger GD image system designed to help site owners make a good looking directory right out of the box.

    Featured Images

    The first image listed in the images field is set as the featured image for the post automatically.

    About the API

    Post images are added in add/edit post route with post_images parameters. It can add multiple images to post_images with ::(double colon) separated. Ex: IMAGE_1::IMAGE_2::IMAGE_3
    Each image item contains attributes like url, id, title, caption etc.

    Here is example for adding images via REST API to the listing.
    &post_images=https://www.londoneye.com/media/s2xes0bt/we-re-good-to-go-london-eye.jpg::https://www.londoneye.com/media/joqmuyuq/herohomepage1920x1080.jpg||hero home page|hero home caption

    Here is example for updating images via REST API to the listing.
    &post_images=https://www.londoneye.com/media/s2xes0bt/we-re-good-to-go-london-eye.jpg|23|my title|my caption::https://www.londoneye.com/media/joqmuyuq/herohomepage1920x1080.jpg|24|hero home page|hero home caption

    Additional documentation for the API is available here: https://wpgeodirectory.com/docs-v2/api/

    Thread Starter jormarques

    (@jormarques)

    Hi @alexrollin ,
    Thanks a lot and for the quick reply :), it worked perfectly. Yesterday I tried using the EDIT, but it was not working, in the ADD it works perfectly, I will see what is wrong with my EDIT request, Thank you once again :). Have a great day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘REST API not working with MEDIA’ is closed to new replies.