I took the PHP CodeIgniter website, which dynamically generates modified images and thumbnails.
Here is an example of an img
tag on a site that generates a 100px by 100px thumbnail:
<img src="/media/image/ImageName.jpg/100/100" />
This is generated using the helper:
echo img('media/image/ImageName.jpg/100/100');
There is some logic to the image function in the media controller, which first checks the cache folder and then serves the cached image if it exists.
It still seems like this is not an elegant approach and looking at how other PHP frameworks like SilverStripe do it would be better to do something like this:
echo img_link('ImageName.jpg', 100, 100);
This new img_link
function in the helper will first check the cached image and write the link directly to the image file or generate a new image and send a direct link to html.
My thoughts are that if PHP serves every img
using this type of code
$this->output->set_content_type('jpeg')->set_output(file_get_contents($file_path));
he will always be ineffective.
Anyone's thoughts?
source share