0

For the application I am currently building, there is a dataset of links associated with certain customer profiles and the user receives a list, which looks like the following:

function getList(customItems){
var messageData = {
    recipient: {
      id: recipientId
    },
    message: {
      attachment: {
        type: "template",
        payload: {
          template_type: "generic",
          elements: []
        }
      }
    }
  }; 
customItems.forEach(function(item) {
    var url = item._id;

    var listItem = {
      title: item.title,
      subtitle: "",
      item_url: url,
      image_url: "http://random.image.com",
      buttons: [{
        type: "postback",
        title: "Get other items",
        payload: "TEST",
      }]
    };

    messageData.message.attachment.payload.elements.push(listItem);

Anyway, I would like to generate some image from given url the same way it appears in messenger if the link is pasted directly into the text box and haven't figured out yet how to do it. Also, by the way, if I try to display some random image for testing purpposes (http://random.image.com replaced by some valid image url), the image doesn't appear.

Does anyone know how to generate images to be displayed for given urls dynamically?

Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286

1 Answers1

0

You either have to implement your own (or open source) thumbnail image processor (with something like ImageMagick, GraphicsMagick, G'MIC, gd, PhantomJS + HTML5 Canvas), or use a SaaS solution like imgix.com

Julien
  • 5,243
  • 4
  • 34
  • 35