How to get image source path on page created whit image.php file (<img src="")?

How to get image source path (<img src="")

Is there any way to get source path of an image on page created using image.php file?

An example from demo page on your site http://

www.zenphoto.org/demo/albums/album2/Cosmos06.jpg

If look at the source code of web link above, at the "image section", you will see this:

<div id="image">


<img src="/demo/cache/album2/Cosmos06_595.jpg" alt="Cosmos06" width="595" height="446" />


</div>

What I need is how to echo/print image source path. In example above this:
"/demo/cache/album2/Cosmos06_595.jpg"

It can be very useful. For example, for image licensing, in that case image source path is needed. Look in an example of image license html code below:

Creative Commons some license

Comments

  • Sorry, web link mistake. An example html source code is from this page:
    http://www.zenphoto.org/demo/album2/Cosmos06.jpg.php
  • acrylian Administrator, Developer
    You should escape code correctly.

    You probably are looking for `getFullImageURL`. However `"/demo/cache/album2/Cosmos06_595.jpg"` is the cached sized image, not the full one.

    I suggest to review:
    http://www.zenphoto.org/news/theming-tutorial
    http://www.zenphoto.org/news/functions-documentation

    Most every "print" function has also a "get" variant.
  • Yes, I know it is cached sized image, and I need image source path for that image not for full one.

    I tried with getFullImageURL but I do not get "pretty" path even if page is cached before. Page html source shows:

    <img src="/cache/folder/image_w725_h408.jpg"

    but for getFullImageURL I always get:

    "/zp-core/full-image.php?a=folder&i=image.jpg&q=75"

    How to get: <img src="/cache/folder/image_w725_h408.jpg"
  • `getDefaultSizedImage()` will give you a link that will display the normal sized image. This is what is used in the `printDefaultSizedImage()` function typically used in themes. However, this link may be directly to the cache or may be to the image processor depending if a cached version of the image exists.

    There is not a means of "forcing" the image to be cached so that you can guarentee a link that is not the image processor.
  • I tried that, but even image is cached I do not get image source path of image displayed because I am not using default image size.

    In "printCustomSizedImageMaxSpace" I used custom values, example:

    printCustomSizedImageMaxSpace(getBareImageTitle(),725,725); to best fit page design, so my images are 725 x 408 pixels.

    With getDefaultSizedImage() I get path to image which height is 595, default size I guess (of course if I use printDefaultSizedImage() to make that image first).

    So I tried with printCustomSizedImage() I hooped I will get right image path but I get error.

    If you have any suggestions please let me know.
  • acrylian Administrator, Developer
    If you use "customimage" functions you need to pass parameters to them. Again, "print" functions print html or even html constructs for theming convenience. If you want just the pure date (a path in this case) you have to use the "get" ones.
  • I am not quite sure now, what parameters and where to pass them. Can you give me an example for my case?
  • acrylian Administrator, Developer
    Above you say you don'T use the default size image, so that means your theme uses custom sizes. Then you know what values to pass to the parameters.

    All parameters are documentated on the functions documentation. On the user guide there is also a tutorial how to read that functions guide.

    Also again:
    `image
    => cached sized image
    but for getFullImageURL I always get:

    ' /zp-core/full-image.php?a=folder&i=image.jpg&q=75'
    => yes, as even full images are processed for watermarks (since we are file based it is easier to always do than to check if we need to or not - less overhead). To by pass that you need to use the `getUnprotectedFullImageURL`. Please see the functions documentation for the correct spelling, I don't have it in my head right now.
    `image
    => this is also the cached size image url not the full image one.
  • I tried this:

    `getProtectedImageURL()` and `getFullImageURL();` and I get the same, this:

    `/zp-core/full-image.php?a=folder&i=image.jpg&q=75`

    Also I tried this:
    `getDefaultSizedImage()` and I get this:
    `/zp-core/i.php?a=folder&i=image.jpg&s=595&cw=&ch=&q=85`

    and this:

    `getUnprotectedImageURL()` and I get this:
    /albums/folder/image.jpg

    and this what you told me `getDefaultSizedImageURL` and I get this:
    `Fatal error: Call to undefined function getUnprotectedFullImageURL() in ......image.php on line...`.

    So, whatever I try I can not get this `/cache/folder/image_w725_h408.jpg`
  • acrylian Administrator, Developer
    getProtectedImageURL() and getFullImageURL(); and I get the same, this:

    /zp-core/full-image.php?a=folder&i=image.jpg&q=75

    Yes, as said this is the protected full image url.

    Also I tried this:
    getDefaultSizedImage() and I get this:
    /zp-core/i.php?a=folder&i=image.jpg&s=595&cw=&ch=&q=85

    Yes, that is the url to the yet uncached default sized image.
    getUnprotectedImageURL() and I get this:
    /albums/folder/image.jpg
    I meant `getUnprotectedFullImageURL()`instead I meant getUnprotectedImageURL(). Sorry, I don'T have all correct function names present thus I referred to the functions documentation. So that is the direct url to the full image which I thought you want to get.

    What you actuallywant to get is the cached (sized) image url. As said several times you get that by using the "get" custom sized get functions (be it default, custom or custom maxspace). Since that cached image is not cached automatically but on request it always goes first through `i.php` to create that cached file. Please read
    http://www.zenphoto.org/news/how-does-zenphoto-cache-
    http://www.zenphoto.org/news/is-it-really-necessary-to-pre-cache-my-images-at-all-

    So `/zp-core/i.php?a=folder&i=image.jpg&s=595&cw=&ch=&q=85` is actually the url to an uncached `/cache/folder/image_s595.jpg`
  • Thanks for note. I tried with this:

    `getCustomSizedImageMaxSpace(725,725)`

    And it works fine, of course I needed to pass parameters (725,725) in my case I use that size of image. Now I get right image path.

    Thank you again.
Sign In or Register to comment.