Search code examples
openlaszlodata-urilzx

Does openlaszlo has a feature like data uri?


i want to know wheter open laszlo has data uri feature. The following example will show a red dot where the red dot is an image and base64 data is passed to it. Is it possible to do something like this?

example is given below

<div>
    <p>Taken from wikpedia</p>
    <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
    9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>

Solution

  • You are referring to Data URLs as specified in RFC 2397. That feature not supported in OpenLaszlo, and it only would be relevant for DHTML applications anyway. For the SWF runtime, images can be compiled into a SWF file as static resources, increasing the file size and reducing the number of requests needed to send to the server.

    There are size limitations for inline images as well. Browsers are only required to support URLs up to 1,024 bytes in length, according to the above RFC. Browsers are more liberal in what they'll accept, however. Opera limits data URLs to about 4,100 characters. Firefox supports data URLs up to 100K, which means you should only use the technique for small to medium size images.

    Even though Data URLs are not supported in OpenLaszlo, a similar - and in my eyes - more powerful option is available. The automatic generation of a CSS sprites for images you add as static resources. When you select the 'Use master sprite' compile option, the OpenLaszlo compiler will create one PNG sprite map containing all those static resources.

    OpenLaszlo DHTML Runtime 'Use master sprite' compile option

    Here is an example of the master sprite PNG for the OpenLaszlo weather widget. Instead of making multiple requests to download the individual images, the browser just has to make one request.

    OpenLaszlo weather demo CSS sprite generated by the OpenLaszlo compiler