Home › Forums › Calendar Products › Events Calendar PRO › iCal export does not include attached images
- This topic has 22 replies, 4 voices, and was last updated 8 years, 9 months ago by Support Droid.
-
AuthorPosts
-
February 13, 2012 at 10:35 am #15091StijnMember
We’ve added our events to the The Event Calendar Pro and would like to export all events through the iCal export function. Unfortunately the export does not seem to include attached images.
A single event is made up of the following fields:
BEGIN:VEVENT
DTSTART;VALUE=DATE-TIME:20120407T150000
DTEND;VALUE=DATE-TIME:20120407T150000
DTSTAMP:20120213T173703
CREATED:20120129T130931
LAST-MODIFIED:20120129T130931
UID:2377@http://www.domain.com
SUMMARY:The summary
DESCRIPTION:A lot of text to describe the event
LOCATION:Amsterdam
URL:http://www.domain.com/event/the-event/
END:VEVENTBut when an image is attached to the event/post, I would like to see something like the following appear:
ATTACH;FMTTYPE=image/jpeg:http://domain.com/images/awesome.jpgIs there a way to get the URLs to the attached images for each event in the export?
February 13, 2012 at 5:03 pm #15114RobMemberHi there Stijn, thanks for the note here. You are correct that the image isn’t carried over on the iCal end. If I recall correctly, last time we discussed this there was a technical limitation as to why. But that may have changed.
Let me see if one of our devs can take a look and share their thoughts here. I’ll have someone respond directly if they can. Cheers.
February 14, 2012 at 2:09 am #15135StijnMemberHey Rob, thanks for the quick response! I’d be great if this was possible, otherwise we’ll have to find some workaround…
If there is another way to get a (json) feed of the events on the calendar _with_ image, that would be great as well.
Cheers!
February 14, 2012 at 7:43 am #15144Nick CiskeParticipantStijn,
Can you give us some context for how you’re using the feed? I ask because your example uses URLs for the attachment tag which don’t seem to be supported by iCal or Outlook.
February 14, 2012 at 8:03 am #15146StijnMemberHi Nick,
We’re trying to include the calendar from our (wordpress) website in an iOS application. In order to do this we need some way to import the calendar data in our app and the iCal feed seemed like the best way to do this. If there is another way to accomplish this (like a JSON or XML feed), please let me know.
My example is based on RFC 2445 which describes the iCalendar format if i’m correct.
http://www.ietf.org/rfc/rfc2445.txtIt contains ATTACH lines with an URL in several examples like here:
——————
4.1.3 Binary ContentBinary content information in an iCalendar object SHOULD be
referenced using a URI within a property value. That is the binary
content information SHOULD be placed in an external MIME entity that
can be referenced by a URI from within the iCalendar object. In
applications where this is not feasible, binary content information
can be included within an iCalendar object, but only after first
encoding it into text using the “BASE64” encoding method defined in
[RFC 2045]. Inline binary contact SHOULD only be used in applications
whose special circumstances demand that an iCalendar object be
expressed as a single entity. A property containing inline binary
content information MUST specify the “ENCODING” property parameter.
Binary content information placed external to the iCalendar object
MUST be referenced by a uniform resource identifier (URI).The following example specifies an “ATTACH” property that references
an attachment external to the iCalendar object with a URI reference:ATTACH:http://xyz.com/public/quarterly-report.doc
The following example specifies an “ATTACH” property with inline
binary encoded content information:ATTACH;FMTTYPE=image/basic;ENCODING=BASE64;VALUE=BINARY:
MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1U
EBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIE—————————
This seemed like a solution for our problem, unless I’m missing something?
Thank you for your time!
February 14, 2012 at 8:35 am #15149Nick CiskeParticipantNope, that’s definitely the way to go. I just wanted to know the specific use case as we determine how/when to implement it as the ‘common’ clients don’t seem to support remote (only local) attachments.
If you need an immediate solution, you can add a filter to the ical generation in the iCalFeed() method in events-calendar-pro.php to inject an attachment tag & URL into the iCal feed (based on the event ID).
I think this is going to get on our roadmap, but not for a bit yet (looks like 2.2 at the moment).
February 14, 2012 at 10:09 am #15153StijnMemberAlright, too bad there is no solution ready. If you could give me some additional pointers on how to implement an immediate solution that would be great (maybe you have an example on something similar?). My php is a bit rusty…
Many thanks for your help. If I manage to implement this addition I’ll post it here for everyone to enjoy.
Cheers!
February 14, 2012 at 10:16 am #15154Nick CiskeParticipantWell, this is one of those situations where there is not one solution.
For example, if there is a featured image, is that the attachment? Do we attach all items attached to that post including the featured image? (e.g. a PDF, images in the post body, etc). There’s not a clear 1:1 mapping of WP attachments to iCal attachments, and including all attachments (esp. base64 encoded) could seriously bloat the iCal export (and cause performance issues on busy sites).
A filter allows the user to make those determinations themselves, but does require some PHP skills.
A more fully fledged feature will probably have to options to configure attachment behavior, but that takes time and discussion… and 2.1 is in feature freeze. Sorry!
February 15, 2012 at 3:40 am #15217StijnMemberTrue.
For our case we just need the urls of the images attached to an event (post) to show up in the feed, but I very much understand your point. I’ll see what I can do for now!
February 15, 2012 at 9:20 am #15221Nick CiskeParticipantStijn,
We’ve added a filter to 2.1 — you can ask Rob for a copy of the dev branch once he’s tested it.
Adding this code in your functions.php or a plugin should do the trick (once you have the new ECP code):
add_filter(‘tribe_ical_feed_item’,’tribe_add_attachment_to_ical’, 10, 2);
function tribe_add_attachment_to_ical($item, $event){
$args = array(
‘post_type’ => ‘attachment’,
‘numberposts’ => -1,
‘post_status’ => null,
‘post_parent’ => $event->ID
);$size = ‘full’;
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$image_attributes = wp_get_attachment_image_src($attachment->ID, $size);
$item[] = “ATTACH:”.$image_attributes[0];}
}return $item;
}Change the $size variable if you don’t want the full size image — check the codex for options.
February 16, 2012 at 6:58 am #15255StijnMemberSounds great! Thanks for the code Nick.
Rob (I hope you still monitor this thread), is it possible to receive a copy of the 2.1 dev branch like Nick suggested? If it is not ready (tested) yet, could you give me an indication of when we could receive it? Also, when is version 2.1 to be released (roughly)?
Thanks
February 16, 2012 at 12:34 pm #15281RobMemberStijn: 2.1 is going to be released by the end of March, but if you email me I can provide you with this. Send an email to pro /a/ tri.be, referencing this thread, and I will provide it to you from there. Thanks!
February 27, 2012 at 7:42 am #15715StijnMemberGuys,
I’ve added the 2.1 plugins you provided to WordPress using the “upload plugin” function. It now shows up next to the version we already had installed (2.0.3) but we deactivated the ‘old’ version.
The plugin works for as far as I tested it, but the iCal export now only includes 10 events instead of all. It appears that changing the “Number of events to show per page in the loop” setting changes the number of events in the iCal export (as well as the number of events on the List page).
I’m not sure if this is intended behaviour for 2.1, but it seems like a bug. What can I do to change it back to export all events? Thanks!
February 27, 2012 at 7:39 pm #15788RobMemberHey Stijn. Thanks for the heads up; I’m oddly not having this problem. Just so I understand: if I set the number of events in the loop to 3, that should mean only 3 events carry over when I do the iCal import, correct? If that’s the case this isn’t occurring for me. Can you clarify that I’ve interpreted the note correctly?
February 28, 2012 at 2:45 am #15825StijnMemberHi Rob. That is correct, when I set the number of events in the loop to 3, only 3 events appear in the ical import. Could it be because we currently have both version 2.0.3 and 2.1 installed (with 2.0.3 deactivated)? Would it help to remove the 2.0.3 version of the plugin, or would that also delete the events data?
Or maybe there is some kind of conflict with another plugin (seems rather far fetched)?
Thanks! -
AuthorPosts
- The topic ‘iCal export does not include attached images’ is closed to new replies.