How do I add an image to an item in RSS 2.0?

后端 未结 9 850
青春惊慌失措
青春惊慌失措 2021-02-03 23:50

Is there a way to send only an Image with a link and some alt text for each item in an RSS feed?

I looked at the enclosure tag but this is only for videos

9条回答
  •  梦毁少年i
    2021-02-04 00:35

    Example in Rome tools (https://rometools.github.io/rome/)

    Item item = new Item();
    
    Enclosure enclosure = new Enclosure();
    
    String imageUrl = "...";
    enclosure.setUrl(imageUrl);
    
    // set corect image type
    enclosure.setType("image/jpeg");
    
    List enclosureList = List.of(enclosure);
    
    item.setEnclosures(enclosureList);
    

提交回复
热议问题