Use the class directly and pass an array of all geodata you want to the $geodata parameter of the constructor. The constructor doc has info how that array has to be setup.
Generally the plugin is setup so you can use it for any kind of geodata, e.g. it must not even use albums/images from Zenphoto itself.
The core of Zenphoto is class based. You basically have to loop through all albums recursively via the gallery class and then album class on each.
You could also get all album names from the database directly but you still need to create album objects and check on them as you otherwise will bypass publish status or protection which is inherited from parents.
I have not found a function to grab all image filenames in subfolders from a parent folder.
Create an album object for an album and get its images via the appropiate method getImages() is the way to do that. Again you have to do this recursively for further levels by using the getAlbums() method of the album object.
Note that you your code does not check for the publish state of the images and getAllSubAlbumIDs() does not check for protection, publish state or if this is a user's album either. You have to use the objects and the related methods as well. Use the function getItemByID() to get an oject from those ids.
Again you should extend the plugin class either theme based or via an additional plugin and modify any method of the original class you need different.
I understood that differently. In a parent album, where there are only sub albums, getAlbums() will deliver the subalbums. In a parent album where there are only subalbums, getImages() = NULL. Everything always works only on the current album. There is no function getImages('any-album'), but only getImages('current-album').
I understood that differently. In a parent album, where there are only sub albums, getAlbums() will deliver the subalbums. In a parent album where there are only subalbums, getImages() = NULL. Everything always works only on the current album.
Yes, but I am not talking about the standard template functions that are procedural.
There is no function getImages('any-album'), but only getImages('current-album').
No, you have to use the object model for that which then provides methods to do that.
Please don't confuse procedural general template functions with class methods. There are sometimes similar named in both.
The article I linked above explains how the object model works with examples. If object orientation in general is new to you please see here: http://php.net/manual/en/language.oop5.php
How does the getAlbumGeodata() function check whether the images are published or locked?
It doesn't itself. Basically the functions/class methods who deliver the data do that and only deliver what is allowed.
I hang. How do I get the latitude and longitude of an image? $imageobject["data"]->EXIFGPSLatitude $imageobject->getImageGeodata() getImageGeodata($imageobject) $imageobject->getGeoCoord() getGeoCoord($imageobject)
don't work by me.
No, because it does not work that way. You cannot use class methods directy…
This should work:
Create an image object of image.jpg in album album;
$albobj = newAlbum('album');
$imgobj = newImage($albobj, 'image.jpg');
$geodata= array(
array(
'lat' => $imgobj->get('EXIFGPSLatitude'),
'long' => $imgobj->get('EXIFGPSLongitude'),
'title' => $imgobj->getTItle(),
'desc' => $imgobj->getDesc(),
'thumb' => '<some html>' // an <img src=""> for example for a thumb or whatever
)
);
Add arrays within the array for every further image.
Then either setup a map object:
$map = new zpOpenStreetMap($geodata);
$map->printMap();
Or use the procedural wrapper: printOpenStreetMap($geodata);
This will get you a map outside any album/image context since you wanted all images. Be aware that hundreds or thousand markers will make the map probably quite slow.
var geodata = new Array();
geodata[0] = {
lat : "12.345",
long : "12.345",
title : "",
desc : "",
thumb : "",
current : "0"
}; geodata[1] = {
lat : "12.678",
long : "12.678",
title : "",
desc : "",
thumb : "",
current : "0"
}; geodata[2] = {
...
printOpenStreetMap($geodata);
or
$map = new zpOpenStreetMap($geodata);
$map->printMap();
The test was in /themes/mybasic/album.php.
Now it should work in /themes/mybasic/index.php.
Problem: getAllAlbums() don't work in /themes/mybasic/index.php.
Of course not, it its either dependend on the current album or you have to pass one.
To get all albums try this:
$toplevelalbums = $_zp_gallery->getAlbums(0);
$albumlist = array();
foreach($toplevelalbums as $album) {
$obj = newAlbum($album);
$albumlist[] = $obj->getID();
// getAllAccessibleAlbums() should assign to $albumlist, it assigns IDs
// only so you need to create objects later again to get their images - other than
// getAllAlbums() this does check for access etc.
getAllAccessibleAlbums($obj);
}
This is untested code, roughly written down rather offhand.
Thank you vincent, but I did not want to use Google Maps anymore, but OSM (and preferably with OpenLayer instead of Leaflet).
It now works with the OSM plugin. An overview in the index.php, an overview in parent albums in the album.php. But there is a problem. As soon as I want to display thumbs in the index.php OSM, there is server timeout. It loads too long. Even larger parent albums and sub-albums load very long. This blocks the page.
Can you speed up the loading?
You have to go through a lot of data and you have to load a lot of thumbs that also need to be generated (if you haven't precached them).
I recommend that you try Vincen'ts trick with the dynamic album. It might indeed be faster.
and preferably with OpenLayer instead of Leaflet
You can of course create your own custom plugin to use that. I choose LeafletJS because I like it better.
I use the theme basic. The problem is: All thumbs are displayed above the map. This also delays the page load time. How can I prevent the thumbs from being displayed?
@acrylian, yes, only ~ 15.000 thumbs had to be created. Here is the on-the-fly not so good. After all thumbs had been created, loading the index.php now takes 15 seconds.
You don't need to use makeAlbumCurrent. You already pass the album object ot hte printOpenStreetMap() function directly.
The problem is: All thumbs are displayed above the map. This also delays the page load time. How can I prevent the thumbs from being displayed?
Create your own specific album layout using the multiple_layouts plugin. Or add a check to the existing album.php theme page to disable thumbs for this specific album.
my tips is to create a map in a page.
basic doesn't support zenpage plugin, so it isn't the rigth way.
where do you add your code? in album.php page?
do you want to have a map only for this dynamic album or for all albums with geotaggued pictures?
in case of you want to have a map only for this dynamic album:
-duplicate album.php (album.php and album_map.php)
-in album.php: remove all code with openstreetmap plugin
-in album_map.php: only add (wherever you want in your code) this code printOpenStreetMap().
for example, you may remove all code to display subalbums and pictures and then you will have only your map)
-in admin>plugin: enable multiple_layouts plugin and check that multiple layouts is enabled for 'album'
-in admin>albums>your_dynamic_album, choose album_map as album layout.
just tested OK with googlemap plugin, but it should be something very similar with zp_OpenStreetMap.
Ok, that works better with album_map.php and multiple_layouts. So I have that in my gallery3.
I do not really need it for every parent album and subalbum.
Now I have some questions.
1.) This dynamic album should not appear in the index page. How can I hide it? I just want to insert a link to this page in the header.
2.) How can I remove the title and description in the popups? I just want to show the thumbs with image page link.
3.) Can I now disable Latitude and Longitude in search settings? That should not be generally available.
There is a big problem with using the search for the map. The result is Double Content/Duplicate Content, which Google punishes with down-ranking. The links in the popups and the page URLs have the following structure: example.com/fotomap/PICT0001.JPG
This is very bad.
Info: https://support.google.com/webmasters/answer/66359?hl=en
What can you do there?
1.) This dynamic album should not appear in the index page. How can I hide it? I just want to insert a link to this page in the header.
Unpublish it.
2.) How can I remove the title and description in the popups? I just want to show the thumbs with image page link.
If you mean the plugin, you have to modify it. As said extend the class via plugin or theme functions to create your own custom version without modifiying the plugin.
3.) Can I now disable Latitude and Longitude in search settings? That should not be generally available.
Those are options. Look at the general functions getOption and setOption. You can set them temporarily.
The result is Double Content/Duplicate Content, which Google punishes with down-ranking.
Besides taht Google is a bit more clever than in the past. Use the html_meta_tags plugin and enable the canonical url option.
The plugin html_meta_tags with canonical does not work that way. http://forum.zenphoto.org/discussion/1410005/plugin-html-meta-tags-canonical-url/
I would prefer it, if search results are not displayed as independent albums, but are always linked to the image in the correct album. Do you have a hint for me, how can I realize that?
I saw your pull request and will look at it. I also saw the forum post about the html_meta_tags plugin. Really no need to post the same things several times.
If you are within a dynamicalbum the image pages have the url of that dynamic album. Otherwise it is complicated and confusing, to stay in album context and for visitors if the url constantly changes. That's why there is the canonical url option of the html meta tags plugin…
Images in search results are always dynamic albums. But albums in search results link to the original, there is nothing dynamic.
I know that with the independent (dynamic) albums and it has its advantages. And dynamic albums are independent of what I want.
I'm just looking for a way to break this process. Currently, the maps are in a dynamic page that consists of a search result. In search results albums are linked autonomous. How can I achieve this with images in search results?
Which original more complicated solution?
The maps directly in the startpage is bad because the page has too long load times (20 seconds and more).
The one via thet object model we discussed before Vincent suggested using an dynamic album.
But albums in search results link to the original, there is nothing dynamic.
Yes, search results and dynamic albums are not exactly the same and not meant to. Search results link to the original place. All else would be rather confusing.
Comments
Use the class directly and pass an array of all geodata you want to the
$geodata
parameter of the constructor. The constructor doc has info how that array has to be setup.Generally the plugin is setup so you can use it for any kind of geodata, e.g. it must not even use albums/images from Zenphoto itself.
I have never done anything with classes. This is absolutely new for me.
First question: I do not understand how I get to the images of the subfolders.
The core of Zenphoto is class based. You basically have to loop through all albums recursively via the gallery class and then album class on each.
You could also get all album names from the database directly but you still need to create album objects and check on them as you otherwise will bypass publish status or protection which is inherited from parents.
Basics of the object model behind everything:
http://www.zenphoto.org/news/zenphotos-object-model-framework/
I have not found a function to grab all image filenames in subfolders from a parent folder.
I will rewrite the
function getAlbumGeodata($album) {
with (not finally, in progress)And than i can display the
zpOpenStreetMap()
in parent folders, i think. But for today is enough.Create an album object for an album and get its images via the appropiate method
getImages()
is the way to do that. Again you have to do this recursively for further levels by using thegetAlbums()
method of the album object.Note that you your code does not check for the publish state of the images and
getAllSubAlbumIDs()
does not check for protection, publish state or if this is a user's album either. You have to use the objects and the related methods as well. Use the functiongetItemByID()
to get an oject from those ids.Again you should extend the plugin class either theme based or via an additional plugin and modify any method of the original class you need different.
I understood that differently. In a parent album, where there are only sub albums,
getAlbums()
will deliver the subalbums. In a parent album where there are only subalbums,getImages() = NULL
. Everything always works only on the current album. There is no functiongetImages('any-album')
, but onlygetImages('current-album')
.How does it work?
How does the
getAlbumGeodata()
function check whether the images are published or locked?http://docs.zenphoto.org/source-function-getAlbumGeodata.html#278-295
getImages()
is not in the documentation.An album can have both images and sub albums.
Yes, but I am not talking about the standard template functions that are procedural.
No, you have to use the object model for that which then provides methods to do that.
Please don't confuse procedural general template functions with class methods. There are sometimes similar named in both.
The article I linked above explains how the object model works with examples. If object orientation in general is new to you please see here:
http://php.net/manual/en/language.oop5.php
It doesn't itself. Basically the functions/class methods who deliver the data do that and only deliver what is allowed.
I hang. How do I get the latitude and longitude of an image?
$imageobject["data"]->EXIFGPSLatitude
$imageobject->getImageGeodata()
getImageGeodata($imageobject)
$imageobject->getGeoCoord()
getGeoCoord($imageobject)
don't work by me.
No, because it does not work that way. You cannot use class methods directy…
This should work:
Create an image object of
image.jpg
in albumalbum
;Add arrays within the array for every further image.
Then either setup a map object:
Or use the procedural wrapper:
printOpenStreetMap($geodata);
This will get you a map outside any album/image context since you wanted all images. Be aware that hundreds or thousand markers will make the map probably quite slow.
Hey, many thanks.
I would never have thought of the solution.
$imgobj->get('EXIFGPSLatitude')
For title and desc only one string is needed?
At thumb HTML img tag must be used?
What happens if I leave title and desc? I do not want to show both.
$imgobj->get('some field')
is the core functionality of the root class. But use appropiate methods if available as they might do some extra stuff.You can use any html here. Just an image or a link wrapping an image or else (be aware this is used within JS so test complicated html beforehand).
Only lat/long is required in that array, leave blank what else you don't need.
...don't work.
this is the
$geodata
PHP array var_dump():This is in the HTML source code:
printOpenStreetMap($geodata);
or
display no map, only a grey box.
My mistake. I started the array $geodata with 1. Why? I forgot. With 0 it works.
The test was in /themes/mybasic/album.php.
Now it should work in /themes/mybasic/index.php.
Problem:
getAllAlbums()
don't work in /themes/mybasic/index.php.Of course not, it its either dependend on the current album or you have to pass one.
To get all albums try this:
This is untested code, roughly written down rather offhand.
hi,
I wrote a tip to have a map of all geotagued pictures with googlemap plugin: http://www.vincentbourganel.fr/news/map-of-geo-localized-pictures/
my map works with this:http://www.vincentbourganel.fr/pages/map/
maybe, could be used with zpOpenStreetMap plugin.
Using a dynamic album is of course a way as well and should work.
Thank you vincent, but I did not want to use Google Maps anymore, but OSM (and preferably with OpenLayer instead of Leaflet).
It now works with the OSM plugin. An overview in the index.php, an overview in parent albums in the album.php. But there is a problem. As soon as I want to display thumbs in the index.php OSM, there is server timeout. It loads too long. Even larger parent albums and sub-albums load very long. This blocks the page.
Can you speed up the loading?
You have to go through a lot of data and you have to load a lot of thumbs that also need to be generated (if you haven't precached them).
I recommend that you try Vincen'ts trick with the dynamic album. It might indeed be faster.
You can of course create your own custom plugin to use that. I choose LeafletJS because I like it better.
Hey, vincent, it works! But...
The settings:
words=*&searchfields=exifgpslatitude,exifgpslongitude&inalbums=0&inimages=1&unpublished=0
I use the theme basic. The problem is: All thumbs are displayed above the map. This also delays the page load time. How can I prevent the thumbs from being displayed?
@acrylian, yes, only ~ 15.000 thumbs had to be created. Here is the on-the-fly not so good. After all thumbs had been created, loading the index.php now takes 15 seconds.
You don't need to use
makeAlbumCurrent
. You already pass the album object ot hteprintOpenStreetMap()
function directly.Create your own specific album layout using the multiple_layouts plugin. Or add a check to the existing
album.php
theme page to disable thumbs for this specific album.my tips is to create a map in a page.
basic doesn't support zenpage plugin, so it isn't the rigth way.
where do you add your code? in album.php page?
do you want to have a map only for this dynamic album or for all albums with geotaggued pictures?
in case of you want to have a map only for this dynamic album:
-duplicate album.php (album.php and album_map.php)
-in album.php: remove all code with openstreetmap plugin
-in album_map.php: only add (wherever you want in your code) this code
printOpenStreetMap()
.for example, you may remove all code to display subalbums and pictures and then you will have only your map)
-in admin>plugin: enable multiple_layouts plugin and check that multiple layouts is enabled for 'album'
-in admin>albums>your_dynamic_album, choose album_map as album layout.
just tested OK with googlemap plugin, but it should be something very similar with zp_OpenStreetMap.
Ok, that works better with album_map.php and multiple_layouts. So I have that in my gallery3.
I do not really need it for every parent album and subalbum.
Now I have some questions.
1.) This dynamic album should not appear in the index page. How can I hide it? I just want to insert a link to this page in the header.
2.) How can I remove the title and description in the popups? I just want to show the thumbs with image page link.
3.) Can I now disable Latitude and Longitude in search settings? That should not be generally available.
There is a big problem with using the search for the map. The result is Double Content/Duplicate Content, which Google punishes with down-ranking. The links in the popups and the page URLs have the following structure:
example.com/fotomap/PICT0001.JPG
This is very bad.
Info: https://support.google.com/webmasters/answer/66359?hl=en
What can you do there?
Unpublish it.
If you mean the plugin, you have to modify it. As said extend the class via plugin or theme functions to create your own custom version without modifiying the plugin.
Those are options. Look at the general functions
getOption
andsetOption
. You can set them temporarily.Besides taht Google is a bit more clever than in the past. Use the html_meta_tags plugin and enable the canonical url option.
Many thanks for answers.
I have make a Fork of the plugin and have expand it.
Pull request: https://github.com/acrylian/zp_openstreetmap/pull/12
The plugin html_meta_tags with canonical does not work that way.
http://forum.zenphoto.org/discussion/1410005/plugin-html-meta-tags-canonical-url/
I would prefer it, if search results are not displayed as independent albums, but are always linked to the image in the correct album. Do you have a hint for me, how can I realize that?
I saw your pull request and will look at it. I also saw the forum post about the html_meta_tags plugin. Really no need to post the same things several times.
There is nowhere the correct URL to the image pages deposited.
It can be used the "webpath" with
preg_replace
, but it is not correct either.Here is a solution for the
zp_openstreetmap
plugin.zp_openstreetmap.php
Original:
getCustomImage(150, NULL, NULL, NULL, NULL, NULL, NULL, true) . "' alt='' />";Hack:
getCustomImage(150, NULL, NULL, NULL, NULL, NULL, NULL, true) . "' alt='' />";Consider that otherwise the thumbs in the maps popups are linked to an album, where all images of the entire gallery are listed.
Stop! These links also link to an album in which all images of the entire gallery are listed.
I have no solution ...
If you are within a dynamicalbum the image pages have the url of that dynamic album. Otherwise it is complicated and confusing, to stay in album context and for visitors if the url constantly changes. That's why there is the canonical url option of the html meta tags plugin…
preg_replace('/^\/albums/', "", $image->webpath) . "
Don't understand this. This is an image page url that is not supposed to include the
albums
folder.If you don't want that you need to return to the original more complicated solution.
Images in search results are always dynamic albums. But albums in search results link to the original, there is nothing dynamic.
I know that with the independent (dynamic) albums and it has its advantages. And dynamic albums are independent of what I want.
I'm just looking for a way to break this process. Currently, the maps are in a dynamic page that consists of a search result. In search results albums are linked autonomous. How can I achieve this with images in search results?
Which original more complicated solution?
The maps directly in the startpage is bad because the page has too long load times (20 seconds and more).
The one via thet object model we discussed before Vincent suggested using an dynamic album.
Yes, search results and dynamic albums are not exactly the same and not meant to. Search results link to the original place. All else would be rather confusing.