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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:51:49+00:00 2026-05-12T16:51:49+00:00

I am trying to do the following in my web application: <img src=static.example.com/image01.jpg?width=300&height=300 />

  • 0

I am trying to do the following in my web application:

<img src="static.example.com/image01.jpg?width=300&height=300" />

Is it possible to have my server (I use Apache in a shared hosting environment) run a PHP script when accessing a .jpg (or any filetype that I chose) instead of just serving the file?

I know that the PHP script has to set the right headers etc, I’m just wondering how it can be run in the first place.

I know this can be done as so :

<img src="static.example.com/get_image.php?name=image_01.jpg&width=300&height=300" />

but that’s not how I would like to have it.

  • 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-05-12T16:51:49+00:00Added an answer on May 12, 2026 at 4:51 pm

    You could use mod_rewrite provided you are in a subdirectory, or that is all your other static.example.com will be doing.

    Add something like this to your .htaccess in that subdirectory.

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteCond %{query_string} ^height=([^&]+)&width=([^&]+)
       RewriteRule (.*\.jpg|.*\.png|.*\.gif) controller.php?name=$1&height=%1&width=%2
    </IfModule>
    

    EDIT: Try the above. Like everything else, untested… 🙂

    The order of the GET parameters becomes important.

    test.jpg?height=100&width=120
    

    should get turned into

    controller.php?name=test.jpg&height=100&width=120
    

    Another approach would be to make apache serve .jpg as php scripts for that directory.
    Just look in your httpd.conf or php.conf and look for .php. Find that directive, and duplicate it within a <Directory> for .jpg.
    I’ve never actually tried this for a single directory, but ultimately it would be faster than the mod_rewrite route.

    Something like:

    <Files *.jpg>
    SetOutputFilter PHP
    SetInputFilter PHP
    </Files>
    AddType application/x-httpd-php .jpg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do the following: User goes to web page, uploads XLS file
I was trying the following example, but with external URLs: Using WebViews The example
I am trying the following code: <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link)
I'm new to Ruby, and I'm trying the following: mySet = numOfCuts.times.map{ rand(seqLength) }
I'm trying out the following query: SELECT A,B,C FROM table WHERE field LIKE 'query%'
I've ran into a problem while trying to test following IRepository based on NHibernate:
I'm following several tutorials and references trying to get my kernel set up. I've
I'm trying to get the following bit of code to work in LINQPad but
I'm trying to bind the following shortcut: Ctrl + W to close tabs How
I'm trying to use the following code but it's returning the wrong day of

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.