Member
Member
vincent3569   06-01-2012, 12:00
#1

hi

I wish to acess to the image object of a specific image.
I only know his path on the server (albums/album_1/image_1.jpeg for exemple).

How can I do that with the different existing functions ?

Thanks for your help.

Administrator
Administrator
acrylian   06-01-2012, 14:19
#2

You have to create the object to do so if it is not the current image you wish to use. You find a tutorial about the object model on our user guide.

Member
Member
sbillard   07-01-2012, 00:31
#3

More specifically, first you will have to create an album object to the album the image resides in, then using that object, create an image object. If you want that image to behave like the "current" image, then there is a function to do so.

Member
Member
vincent3569   07-01-2012, 17:37
#4

thanks for your help

I do like that :

`

`
It works well.

Maybe, it would be a good idea to have a function which allow to directly access to the image object of a specific image.
Something like that:
$imageobject = FunctionName($galleryobject, "/album_name/image_name.jpg");

Member
Member
vincent3569   07-01-2012, 17:40
#5

btw, there is a mistake on http://www.zenphoto.org/news/zenphotos-object-model-framework.

in

Note that "folder name" means the name of the real folder on the filesystem within the root "albums" folder of your installation. If you want to create an object of a subalbum the name must include the parent album name(s) like "toplalbumfoldername/subalbum1folder/subalbum2folder" (etc);

there is a missing "/" and it should be :

"/toplalbumfoldername/subalbum1folder/subalbum2folder" (etc);

Administrator
Administrator
acrylian   07-01-2012, 18:52
#6
  1. If you are on Zenphoto theme pages you don't need to create the gallery object as that is already present in the global $_zp_gallery always. Not sure, if the check if the image exists is really needed as it otherwise should not be able to create an image object (sbillar might correct me though)

  2. I doubt that we will make a function for image object as that would just save one line of code actually.

  3. You actually don't need the trailing slash at all. "albumname/subalbumname" is enough.

Member
Member
sbillard   07-01-2012, 19:16
#7

zenpageAlbumImage() exits.

Member
Member
vincent3569   07-01-2012, 20:18
#8

with my tests, without the slash, I can't access to the picture :
"if (is_object($imageobject) && $imageobject->exists)" returns always false.

I will have a look on the function above (tanks for your advise)

Member
Member
sbillard   07-01-2012, 21:04
#9

Check your debug log to see what it has reported. There should be some indicator of why the image/object instantiation failed.

Member
Member
vincent3569   07-01-2012, 22:02
#10

@acrylian

1- if I write :
`

`
I have this error in debuglog :

Quote:{Sat, 07 Jan 2012 20:55:48 GMT} Zenphoto v1.4.1.5[8326]
Backtrace: Bad gallery in instantiation of album groupe-photo-ecully/portraits-low-key.
Album->Album called
from eval (template-functions.php(4699) : eval()'d code [21])
from printCodeblock (template-functions.php [4699])
from include (pages.php [12])
from include (index.php [5])
from index.php [155]
so I need the creation of a gallery object.
fyi, this code is used on personnnal home page, to display a slideshow.

3- you are right, the slash at the begenning is not required (I don't know where my mistake was)

Administrator
Administrator
acrylian   08-01-2012, 11:18
#11
  1. It is important where you write this code. If it is within a custom function or a code block (which is within a function as well) the global is not available so you need to create the gallery first.

@sbillard: We might reconsider the recent change ignoring the "$gallery" parameter. Maybe just a check if the global $_zp_gallery is set would be the way to allow both ways. (or maybe we just add the global to the codeblock, which they probably don't have being Zenpage functions).

  1. Sorry, I meant the starting slash (somehow confused that with trailing...).
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.