Forum Discussion

TeenaFrancis's avatar
9 years ago

REST API extract image from article body

Hi,

Is there a way to extract images from an article body using REST API. My aim is to give a summary of recent article in my community dashboard page by putting the images of recent articles along with article title. The rest api(http://xxxxxxxxxxxxxxxxx.lithium.com/restapi/vc/blogs/id/Blog1/threads/recent?page_size=1&restapi.format_detail=full_list_element) gives me the entire body with images as an html. How can I take the images from that to give it in my page?

 

Thanks,

Teena

6 Replies

  • TeenaFrancis's avatar
    TeenaFrancis
    Ace
    9 years ago

    Hi Varun,

     

    Thanks for the reply. My call returns like the below screen shot. How should I give images to the article so as to come in the API response?

     

    Thanks,

    Teena

  • rahulsrao24's avatar
    rahulsrao24
    Guide
    8 years ago

    how can we extract an image from the article body using LIQL query ?

  • Payal's avatar
    Payal
    Director
    8 years ago
    Hi rahulsrao24,

    You can extract images from the article by using following LIQL query:

    SELECT * FROM images WHERE messages.id = '[ID]'

    LMK if this works for you.

    Thanks!!
  • Hello,

     

    I tried the the query on the API browser. 

     

    The status of the query shows as Success. But the result set shows up as empty though there are images 

     

    in the body of the article. 

  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    Hi rahulsrao24  Both the queries(V1 & V2) would work perfectly.

    /restapi/vc/messages/id/[ID]/images
    SELECT * FROM images WHERE messages.id = '[ID]'

    But these APIs would not fetch the images which are not hosted on lithium.  
    As in attached image, there are two images one hosted on lithium and other one hosted somewhere else.  Here API would fetch only one image which is hosted/uploaded on the lithium community
    On the front end, both images will look same but you can check the difference in HTML mode(edit message --> Select HTML tab) of the message.  Lithium uploaded images would be wrapped inside the <li-image>.




    images.png