Gif images don't play in Microsoft Teams

Marcos Z. picture Marcos Z. · Dec 21, 2016 · Viewed 7.9k times · Source

I'm using the following code to display a gif image as an attachment in my reply:

    Activity replyToConversation = (Activity)context.MakeMessage();
    replyToConversation.Attachments = new List<Attachment>();
    replyToConversation.Attachments.Add(new Attachment()
    {
       ContentUrl = "http://i.giphy.com/p3BDz27c5RlIs.gif",
       ContentType = "image/gif"
    });

    await context.PostAsync(replyToConversation);
    context.Wait(MessageReceivedAsync);

In the Web Chat channel it displays (and play) as expected, but for some reason it displays as a static image in the Microsoft Teams channel.

Please, any ideas?

Answer

Michael C picture Michael C · Mar 28, 2018

As a workaround you can return an HTML string nesting the image

 await context.PostAsync($"<img src=\"{imageUrl}\" />");