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 9002887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:37:57+00:00 2026-06-16T00:37:57+00:00

I am developing a site framework in php (codeigniter) and want to introduce image

  • 0

I am developing a site framework in php (codeigniter) and want to introduce image versioning on image uploads so that I can take advantage of image caching. The easiest approach would just be to md5 the image and use that as the file name but I don’t like this approach for the following reasons:

1)Not SEO friendly on the image names

2)md5 hashes seem unnecessarily long – and therefore larger database
field required.

So I am considering using an approach such as the following:

Start the filename with the entered name of the image with underscores instead of spaces then add a randomly generated integer, say 8 digits long. This will mean I have to check for an existing image by that name and then regenerate the integer if one exists (however unlikely that is).

Presumably I will also have to unique filename for every image size, so I guess the solution here would be to add a prefix representing the file size.

Now I want to get this right first time since it will be a pain to change once the framework is deployed so I am really just looking for input on

a)Whether my concerns are justified (particularly does the filename do
anything for SEO and does the length of a random string of numbers
affect it)

b)Whether there is anything else I should be concerned about or check
for with my proposed approach.

c)Is there an easier approach, perhaps a hashing algorithm which
produces much shorter results.

d) Is there already a ci lib out there that does this?

Thank you for your input and advice

  • 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-16T00:37:58+00:00Added an answer on June 16, 2026 at 12:37 am

    This answers a few of your questions:

    Replacing spaces with underscores is not enough to have a clean filename as you’d need to check for more weird characters, but you can use sanitize_filename() method in CI’s security library: http://ellislab.com/codeigniter/user-guide/libraries/security.html

    If you do want to preserve the original filename, your approach sounds good to me. Though, 8-digit integer at the end of filename can be replaced by ‘-1’, ‘-2’, ‘-3’ by simple incremental loop checking if the file with that ending exists or not.

    File Upload library is something you can check out – http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html. It is flexible and can be configured to keep the original filenames. Getting sanitize_filename() from Security lib to work along should do exactly what you need.

    In all my CI applications I always use encrypted filename (this optional feature is provided by CI file upload class). At the same time I can configure the library to not overwrite already existing file by adding a number to it (if no encryption is used) or by just giving it another encrypted name (when encryption option is on). I do like it this way as it keeps the filenames consistent clean (although long and not SEO-friendly, however ALT tag gives it more exposure to search engines).

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

Sidebar

Related Questions

Hello everyone, I'm developing a photo sharing web site using the CodeIgniter PHP framework
I'm developing a mobile site using IUI . It's a framework that makes web
I am developing a web book application using the PHP framework CodeIgniter. Users will
I am considering php framework Codeigniter & Cakephp for small site I would be
I'm developing a web site using codeigniter framework. To document it, I've installed doxygen.
I have a simple Zend Framework site I am developing with the addition that
I am developing using CodeIgniter framework. I have an image upload folder which permission
I am developing a crowd-funding site (similar to Kickstarter ) using the CodeIgniter framework.
I'm developing a site using the CakePHP framework. I have a form which shows
I'm developing web site that loads pages dynamically using the .load function. For example:

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.