Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:31:48+00:00 2026-06-03T14:31:48+00:00

I have taken over a CodeIgniter PHP site that dynamically generates resized images and

  • 0

I have taken over a CodeIgniter PHP site that dynamically generates resized images and thumbnails.

Here is an example of an img tag in the site that generates a 100px by 100px thumbnail:

<img src="/media/image/ImageName.jpg/100/100" />

This is generated by using the helper:

echo img('media/image/ImageName.jpg/100/100');

There is some logic in the image function in the media controller, which first checks a cache folder and then serves the cached image if it exists.

It still seems that this is not an elegant approach and looking at the way other PHP frameworks like SilverStripe do it, it would be better to do something like this:

echo img_link('ImageName.jpg', 100, 100);

This new img_link function in a helper would check for the cached image first and write the link directly to the image file or generate the new image and pass the direct link to the html.

My thoughts are that if PHP is serving every img using this type of code

$this->output->set_content_type('jpeg')->set_output(file_get_contents($file_path));

it will always be inefficient.

Thoughts anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:31:50+00:00Added an answer on June 3, 2026 at 2:31 pm

    I agree, I have done exactly what you are proposing (writing the link directly if it is already cached) and it works fine.

    The only time I can think you would get caught out is if your html is cached and you have deleted the cached image, so the direct link to the imagefile is now broken.

    In my case I have never had to remove the cached images, so have not struck that yet.

    The only other case where I can see it being a problem is if you have private images. In that case php would need to check who has permission first before displaying the image, you couldn’t just serve up the cached file as a directlink, as people could share that direct link, and the security would no longer apply.

    If you do need to do that, and you are able to install modules on apache (assuming you are using apache), there is a module “x-sendfile” which will let you handover the file delivery process back to apache, instead of via php. This is good for big files where php could timeout, etc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have taken over some .NET 1.1 Windows Service code that spawns threads to
i have taken over a database that stores fitness information and we were having
I have taken over some work on an existing system that uses NVelocity templates.
I have taken over support of a VB .Net application that makes use of
I have taken over a project that has a lot of code that is
I have taken over a medium sized project that was written originally using RoR.
I have just taken over someone's hosted WordPress site. How do I find out
I have recently taken over an application that uses the Peter Blum Date and
i have taken over a website that has tons of css files and lots
I have taken over a Windows-CE 6.0 application that I would like to port

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.