How to poll for new pictures added?

How can I easily check on my zenphoto site if a new picture has been added?

I don't know what the official term for something like this is (that's why I'm not finding $#@! on google and need your help).

Ideal case I would like www.mysite.com/newpic.php to return either a number (# of pictures on the site), or a timestamp of latest picture added, or a hash value. I don't mind. But not a full page and preferably also not a RSS feed, it's for a mobile purpose.

Is there anything in zenphoto or out there as extension? Otherwise I'd have to do it myself...
thanks!

Comments

  • acrylian Administrator, Developer
    Several ways:
    - Use the functions the image_album_statistics plugin provides to show latest images.
    - Use the Zenpage CMS plugin with a supporting theme and its CombiNews mode to show images within the news section

    Also there is of course RSS available.

    If that all is easy depends on your knowledge of webtechniques. In any case it is recommended to get familiar with how Zenphoto themes work by reading the theming tutorial.
  • Thanks! These are options but I'd like to fetch only (let's say) 64 bytes and do a check "yes/no new content".

    I might end up using PHP to md5 the latest image, not a bad idea.
  • acrylian Administrator, Developer
    I don't know what you mean with fetching 64bytes exactly. But what I described is the way to get new/latest images. From there on you can do whatever checks you want. There is also the object model.

    There is also a flag_thumbnail that can flag (!) thumbs to mark them visually as new within albums. You can even set the date range something is considered new.
  • For people that would ever need something the same, it was easy, most work is figuring out what your mysql access codes are.
    This php code, named "count_pictures.php" will display nothing but number of images registered in zenphoto. It is was I needed. (The output is less than 64 bytes)

    `
    <?php

    $link = mysql_connect('localhost',....);
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    if (!mysql_select_db(...)) {
    die('Could not select database: ' . mysql_error());
    }
    $result = mysql_query("SELECT count(*) FROM <code>zp_images");
    if (!$result) {
    die('Could not query:' . mysql_error());
    }
    echo mysql_result($result, 0);

    mysql_close($link);
    ?>
    `
  • acrylian Administrator, Developer
    So you want just the total count of images... That you could have got even easier.... You really should use the object model then:
    `$count = $_zp_gallery->getNumImages(0)`
    http://www.zenphoto.org/documentation/classes/Gallery.html#methodgetNumImages
  • If you insist this is better even in a standalone php script I can do it.
    What list of includes are necessary, how would a standalone .php look like?
  • acrylian Administrator, Developer
    So you actually want to use that outside Zenphoto (you didn't specifially tell that..). Then see this: http://www.zenphoto.org/news/zenphoto-as-a-plug-in-using-zenphoto-functions-from-outside-zenphoto
  • thanks, I can use this for future enhancements
Sign In or Register to comment.