Hi Simon,
This is what i've used for a rss feed:
<% String serveraddress = "http://" + request.getServerName(); %>
<mm:node element="images"><% String ckey = ""; // resize to 50x37 for Omroep.nl %>
<mm:field name="number" jspvar="img" vartype="String" write="false">
<% ckey = "ckey='" + img + "s(50x37!)'"; %>
</mm:field>
<enclosure url="<%= serveraddress %><mm:image template="s(50x37!)" />"
length="<mm:listnodes type="icaches" constraints="<%= ckey %>">
<mm:field name="filesize" />
</mm:listnodes>"
type="image/<mm:field name="itype" />" />
</mm:node>
It looks a lot like Michiel's, but this is proven technology ;-) It works on MMBase 1.7.
---Andr�
At 12:59 +0100 10-03-2005, Simon Groenewolt wrote:
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:
<?xml version="1.0"?>[snip]
<%@ 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
-- Andr� van Toly http://www.toly.nl mobile +31(0)627233562 ------------------------------------------------------------------>><<-- _______________________________________________ Developers mailing list [email protected] http://lists.mmbase.org/mailman/listinfo/developers
