Search code examples
pythonimageicalendar

How to add an image to an event in Python's icalendar?


I am using icalendar to create an ical file. I want to include an image with each event. According to the spec this is supported through the following format:

IMAGE;VALUE=URI:https://example.com/images/party.png

I don't get icalendar to output this. I tried this:

event.add('image', 'VALUE=URI:%s' % image_url)

And this results in the following output:

IMAGE:VALUE=URI:https://example.com/images/party.png

As you can see, the image is followed by a colon instead of a semicolon. What causes this? How can I add an image to an ical file?


Solution

  • The 'VALUE=URI' part is a property parameter. So it is not to be added in the value directly. Don't know much about this particular API but you need to do something like:

    event.add('image', image_url, parameters={'VALUE': 'URI'})