Howto: Image Output From Joomla 1.5

Now I know how to output image or any other type from Joomla 1.5. Before this I've already made my extension to output image from Joomla in the hard way, I simply use die(); to cancel all others html ouput from Joomla. Since I can't find any tutorial on how to done this things in internet.

So, first thing I looked up to is how to make Joomla print out RAW data. In the older version, we may use 'no_html=1' in our request, for example append this after your server url ( http://joomlaserver/ ):

index.php?option=com_extension&no_html=1

index.php?option=com_extension&format=raw

First line above will tell Joomla 1.0 not to output any HTML but the component's output. Use one of those two lines above to tell Joomla 1.5 to output anything the component wants to print out as is without any Joomla's header or footer.

After I've figured it out how to do raw print out, my second task is to make my component print out its own header. So I add this line of code ( in my case, it'll output jpeg image on the fly ):

header("Content-type: image/jpeg");
header('Content-Disposition: inline; filename=image.jpg');
header("Pragma: no-cache");
header("Expires: 0");
echo $myImageBinarySource;

And I'll get my image output from Joomla 1.5 framework in clean and clear code.

Tidak ada komentar:

2018: Tahun Baru Motivasi Baru

Tahun Baru 2017 sudah lewat, sekarang sudah 2018. Tahun berganti seperti yang sudah-sudah, setahun lagi juga akan berganti menjadi 2019. ...