fullcalendar

FullCalendar - Images as events


Looking to use Full Calendar and to include images as events and draggable. In short, would love to see how this example https://fullcalendar.io/js/fullcalendar-3.0.1/demos/external-dragging.html would work with small thumbnails instead of the text "My Event 1, My Event 2" etc. And have that image show up on the calendar.

Thanks in advance.


Solution

  • You can add any image url to your eventObject by adding the attribute "imageurl" inside of the events definition (if you just want the image, don't specify a title):

    events: [
        {
            title  : 'event',
            start  : '2016-10-12',
            end  : '2016-10-14',
            imageurl:'img/edit.png', //you can pass the image url with a variable if you wish different images for each event 
            .
            .
            .
        }
    

    After that, you add the following code in the eventRender, which will add the image icon to the event (16 width and height is a good size for a thumbnail):

    eventRender: function(event, eventElement) {
        if (event.imageurl) {
            eventElement.find("div.fc-content").prepend("<img src='" + event.imageurl +"' width='16' height='16'>");
        }
    },
    

    For further details refer to this question: Add Icon(s) in first line of an event (fullCalendar)