Reputation: 3880
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
Upvotes: 4
Views: 6281
Reputation: 51
For this sample i don't know what does it mean But it's possible to write
<img src="path_img.png?<?php time() ?>" />
to force your browser to download resource without using cache
Upvotes: 1
Reputation: 20286
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
Upvotes: 6
Reputation: 10189
The arguments in a url are mostly used for getting some information about a specific item but can be used in more other ways. When talking about the images, the browser won't ignore the argument value=23
but the server you are using will.
But if the image is some sort of dynamic then it may be used in order to change the image's URL or other things.
Upvotes: 0
Reputation: 12420
It sure does!
For example, take a look at this piece of software that is intended to dynamically resize an image.
http://imageresizing.net/docs/basics
If done correctly, adding parameters to an image url could be very useful.
Edit:
As others point out, you need to ensure that the server knows how to handle the extra parameter. In this case it is intended to resize/watermark/rotate an image. It can certainly do other wonderful things.
Upvotes: 1
Reputation: 18891
The value=23
only has an effect if the server uses it. The browser requests http://example.com/img.png?valud=23
, so the server will see the parameter.
For example, with PHP, if your use $_GET['value']
, and that variable changes what image is sent, then the value=23
is needed.
Parameters are often sent with images to specify a height or width, or to determine which image is loaded.
Upvotes: 2
Reputation: 21694
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.
Upvotes: 2
Reputation: 11796
value=23
is not ignored by your browser but by the server.
It's like passing parameters to the web server. For images it will be mostly ignored.
Upvotes: 0