Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image with parameter - HTML

Tags:

html

I do not know how to frame the question. And I do not know how the below tag is working...

<img src="img.png?value=23"/>

This tag is working fine. And its rendering the image correctly. Does the value=23 has some effect??? or It is been ignored by Browser??

I do not even know how to Google this!!! Is it like passing parameter to the Image??? If that is the case, how to retrieve the value attribute. Does the parameter has any sense

like image 452
madhairsilence Avatar asked Dec 15 '22 09:12

madhairsilence


2 Answers

It depends on server, if you have png MIME type as text and you parse the files as if they were text files with php code then it has effect.

It really depends on configuration of server not a browser.

Morover, mod_rewrite can be used to change files that look like png to php files.

Adding parsing png files via php parser AddType application/x-httpd-php .png

mod_rewrite

 RewriteEngine On
 RewriteRule ^([a-zA-Z0-9_\-]*)\.png$ img.php?value=$1

With these lineasdfasdf.png will be treated as img.php?value=asdfasdf

So in this case when you use $_GET['value'] on asdfasdf.png or img.php?value=asdfasdf. It will have effect.

If server is not configured to do such things and images are images(Yes i know it's briliant sentence) then it has no effect on common image.

To sum up.

It depends on server configuration not on the browser

like image 87
Robert Avatar answered Jan 11 '23 05:01

Robert


If this image is dynamic in some way, then the server that's hosting this image must be generating the image from PHP code.

Take a look at the GD library, which lets you use PHP to generate images based on nothing or other images. The parameter must be passed to include that value inside the image (for example, an image that includes the text "123" or calculates using it somehow, for example a user ID).

Then an .htaccess on the server rewrites the extension of .png to .php (or maybe another one) to make it look like a genuine image to some libraries and crawlers, or scripts etc.

Another option, is that this is a simple image and that value is being ignored, or is just random to make sure the image isn't cached.

like image 38
casraf Avatar answered Jan 11 '23 03:01

casraf