Image with parameter - HTML

后端 未结 7 1809
半阙折子戏
半阙折子戏 2021-01-14 00:59

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


This tag i

相关标签:
7条回答
  • 2021-01-14 01:37

    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.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-14 01:51

    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

    0 讨论(0)
  • 2021-01-14 01:53

    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

    0 讨论(0)
  • 2021-01-14 01:53

    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.

    0 讨论(0)
  • 2021-01-14 01:56

    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.

    0 讨论(0)
提交回复
热议问题