hi,
I've created an rss feed for our submarine channel site (http://www.submarinechannel.com/rss.jsp) but I had some trouble getting the right image information to add it as an enclosure.
It looks like the taglib currently doesn't provide a way to get the (byte)size of an image (or attachment).
The rss spec says you can add something like this to your feed:
<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
(http://blogs.law.harvard.edu/tech/rss#ltenclosuregtSubelementOfLtitemgt)
This means you need to specify the size and mimetype. The code I came up with to achieve this is:
[snip]<?xml version="1.0"?> <%@ taglib uri="http://www.mmbase.org/mmbase-taglib-1.0" prefix="mm" %> <%@ page import="org.mmbase.module.builders.*, org.mmbase.module.core.*, java.util.*" %>
<mm:relatednodes type="images">
<mm:import id="imagenodenumber" jspvar="imagenodenumber"><mm:field name="number"
/></mm:import>
<%
ImageCaches icaches = (ImageCaches) MMBase.getMMBase().getMMObject("icaches");
List params = new ArrayList();
params.add(imagenodenumber);
%>
<enclosure url="http://www.submarinechannel.com<mm:image template="s(300x300)"/>" length="<%=
icaches.getCkeyNode(imagenodenumber + "s(300x300)").value.length %>" type="<%= icaches.getImageMimeType(params) %>"/>
</mm:relatednodes>
[snip more]
Ooh, the horror! Java code in a page - I'm verry sorry for exposing all of you to this.
And to make matters worse: I get the whole byte[] just to measure it's size! But it works! ;-)
How would I get the size of a (cached) image/attachment in taglib? - is there already a function that I simply missed or do I need to create one? (or a new tag?) I would like to get the size without getting the whole image/attachment to make the script a bit more server-friendly :-)
(and the same for getting the mimetype of an image/attachement)
cheers,
Simon Groenewolt Submarine _______________________________________________ Developers mailing list [email protected] http://lists.mmbase.org/mailman/listinfo/developers
