dannyman.toldme.com

Tuesday October 18, 2016

Photos Flickr Reference Manual


Photos Flickr

    Plugin Name:    Photos Flickr
    Plugin URI:     //dannyman.toldme.com/photos-flickr/
    Author:         Danny Howard
    Author URI:     //dannyman.toldme.com/
    Description:    Photos Flickr is a development version of a plugin
    that I am writing for WordPress blog software to display a user's
    Flickr photos within their blog.
    Version:        0.7.1

So . . . what have we here?

Pretty functions are probably the most interesting -- they do the heavy lifting of printing, say, an index page ...

General functions are the ``worker ants'' which you may call directly, or are in turn used by the pretty functions to get things done. They come in two flavors of name: photos_photo_ and photos_photoset_ depending on whether they are meant to service photo pages or photoset pages.

Private functions are documented for completeness, and for my own sanity. These may be changed at any time. You are welcome to use these, but be warned that you are voiding the warranty, and might get spanked by a future version.

Don't use private functions unless you really know what you are doing.

Obsoleted functions are functions that are no longer supported. A good many are just old names for functions that have been renamed. These are sparingly documented for completeness, and to reassure you that you're not as insane as your friends claim.

Don't use obsoleted functions unless you really really know what you are doing!

PRETTY FUNCTIONS

Top-level functions that implement serious magic and generate copious HTML.

photos_photo_index()

Print a reasonable photo index.

Consults the context in which the page was called, and will print only photos from a photoset or tag, if appropriate. Otherwise, you get the whole photostream.

The semantics of this function changed substantially in 0.8!

 Arguments:
    $num_per_page       = number of photos to print per page
    $num_per_row        = number of photos to print between $row_sep
    $page               = what page number we are printing
    
    $img_size           = what size image to print
    $img_before         = what to print before IMG
    $img_after          = what to print after IMG
    $row_sep            = what to print between rows
    
    $photo_before       = what to print before each photo
    $photo_after        = what to print after each photo
    
    $print_title        = print title?
    $title_before       = what to print before title
    $title_after        = what to print after title
    
    $print_description  = print description?
    $description_before = what to print before description
    $description_after  = what to print after description

You'll end up with a page of photos, and each photo looks something like:

 $photo_before
  $title_before         PHOTO TITLE         $title_after
  $img_before           PHOTO IMG TAG       $img_after
  $description_before   PHOTO DESCRIPTION   $description_after
 $photo_after

For $print_description, if you pass an integer, the description will truncated after $print_description characters.

photos_photo_pageindex()

Prints a ``pagination'' doohickey.

 Arguments:
    $context            = number of adjoining pages to print links to
    $item_sep           = what to put between page links
    $dotdotdot          = what to put between page link sets
    $page               = what page are we on, anyway?

A call like this:

 <?php photos_photo_pageindex(1, ', ', ' . . . ', 5); ?>

Might produce something like this:

1, 2 . . . 4, 5, 6 . . . 68, 69

photos_photoset_index()

Print a reasonable photoset index.

 Arguments:
    $num_per_row        = number of sets to print between $row_sep
    $row_sep            = what to print between rows
    
    $print_thumb        = print thumbnail?  Unless NULL, what kind?
    $print_title        = print title?
    $print_count        = print count?
    
    $photoset_before    = what to print before photoset
    $photoset_after     = what to print after photoset
    
    $thumb_before       = what to print before thumbnail
    $thumb_after        = what to print after thumbnail
    
    $title_before       = what to print before title
    $title_after        = what to print after title
    
    $count_before       = what to print before count
    $count_after        = what to print after count

You'll end up with a page of photosets, and each photoset looks something like:

 $photoset_before
  $thumb_before PHOTOSET IMG THUMBNAIL  $thumb_after
  $title_before PHOTOSET TITLE          $title_after
  $count_before PHOTOSET COUNT          $count_after
 $photoset_after

GENERAL FUNCTIONS

photos_init()

 MANDATORY call once before you call other stuff:
 * Connects to Flickr, setting up phpFlickr handle ($f)
 * Connects to cache database
 * Sets up $person and $nsid for our convenience
 * Sets up $photos_base_url appropriately

TODO: If we are hooking in to WordPress' init() then this should check to see if we're actually doing any photos before it goes pinging Flickr and setting up a database connection, huh?

photos_photo_index_href()

Print a link to a photo index page.

photos_photoset_index_href()

Print a link to a photoset index page.

photos_is_photo()

Are we a page for one photo, or some nav index?

Returns Flickr photo ID of current photo.

Returns false if there is no photo.

photos_is_index()

Are we an index page? If so, what flavor?

Unless we are an photos_is_photo() will return ``index'' or ``photoset''

Returns false if we are not an index.

If we are not a photo or an index, we might be a photoset page, or a tag page ...

photos_is_photoset()

Returns ID of current photoset, else false.

photos_is_tag()

Returns value of current tag, else false.

GENERAL FUNCTIONS: photos_photo_

 TODO: photos_photo_list();
 photos_photo_description();
 photos_photo_href();
 photos_photo_title();
 photos_photo_img();
  
 photos_photo_photoset_list();
 photos_photo_tag_list();

You can pass a photo ID to any of these functions. Otherwise, they'll default to the current photo.

photos_photo_description()

Print photo description.

photos_photo_href()

Print Photos Flickr URL of photo page for $photo_id.

photos_photo_title()

Print photo description.

photos_photo_url()

Print a Flickr IMG link to photo.

photos_photo_photosets()

Print linked photosets for a photo.

photos_photo_tags()

Print a linked list of tags for a photo.

photos_photo_photoset_list()

Returns a PHP list of photosets associated with photo.

Returns False if no photosets. (So you could use it as a boolean check.)

photos_photo_tag_list()

Returns a PHP list of tags associated with photo.

Returns False if no tags. (So you could use it as a boolean check.)

photos_photo_page_url()

Print a link to Flickr photo page

photos_photo_date_taken()

Print the date photo was taken.

Accepts $date_format as second argument -- a format string for PHP's date() function. If this is not supplied, the WordPress date_format option will be checked.

See: http://www.php.net/date

Example:

 photos_photo_date_taken(NULL, 'Y-m-d, H\hi');

(The first argument is the photo ID. NULL means to default to current photo.)

Would print something like:

2007-06-25, 15h58

photos_photo_next_img()

Print IMG link for next photo in stream.

Accepts Flickr image size type as first argument: defaults to ``square''

photos_photo_prev_img()

Print IMG link for previous photo in stream.

Accepts Flickr image size type as first argument: defaults to ``square''

photos_photo_next_href()

Print link to Photos Flickr page for next photo in stream.

photos_photo_prev_href()

Print link to Photos Flickr page for previous photo in stream.

photos_photo_next_title()

Print title of next photo in stream.

photos_photo_prev_title()

Print title of previous photo in stream.

GENERAL FUNCTIONS: photos_photosets_

 photos_photoset_list();
 photos_photoset_description();
 photos_photoset_href();
 photos_photoset_title();
 photos_photoset_img();

These functions generally accept at least one argument: $photoset_id, which is the ID of a Flickr photoset.

photos_photoset_list()

Return a list of photosets associated with $photo_id.

Defaults to returning a list of all sets for user.

Returns False if no photosets.

photos_photoset_description()

Print description of $photoset_id.

photos_photoset_href()

Print Photos Flickr URL of photoset page for $photoset_id.

photos_photoset_title()

Print Title of $photoset_id.

photos_photoset_img()

Print primary image URL of $photoset_id.

photos_photoset_next_img()

Print IMG link for next photo in photoset.

 Arguments:
    $photoset_id    = Flickr ID of photoset
    $thumb_type     = Flickr image size for "thumbnail"
    $photo_id       = Flickr ID of photo

$photoset_id and $photo_id default to current values.

Accepts Flickr image size type as second argument: defaults to ``square''

photos_photoset_prev_img()

Print IMG link for previous photo in photoset.

 Arguments:
    $photoset_id    = Flickr ID of photoset
    $thumb_type     = Flickr image size for "thumbnail"
    $photo_id       = Flickr ID of photo

$photoset_id and $photo_id default to current values.

Accepts Flickr image size type as second argument: defaults to ``square''

photos_photoset_next_href()

Print link to Photos Flickr page for next photo in photoset.

 Arguments:
    $photoset_id    = Flickr ID of photoset
    $photo_id       = Flickr ID of photo

$photoset_id and $photo_id default to current values.

photos_photoset_prev_href()

Print link to Photos Flickr page for previous photo in photoset.

 Arguments:
    $photoset_id    = Flickr ID of photoset
    $photo_id       = Flickr ID of photo

$photoset_id and $photo_id default to current values.

photos_photoset_next_title()

Print title of next photo in photoset.

 Arguments:
    $photoset_id    = Flickr ID of photoset
    $photo_id       = Flickr ID of photo

$photoset_id and $photo_id default to current values.

photos_photoset_prev_title()

Print title of previous photo in photoset.

 Arguments:
    $photoset_id    = Flickr ID of photoset
    $photo_id       = Flickr ID of photo

$photoset_id and $photo_id default to current values.

PRIVATE FUNCTIONS

PRIVATE: photos_init_phpFlickr()

Connects to Flickr, setting up $f

PRIVATE: photos_config_page()

Hooks into WordPress Admin menu to manage options and whatnot.

PRIVATE: get_flickr_user()

Private function to map NSID, username, or e-mail to $flickr_user, which will be an NSID.

Meant to be called by photos_init() as a convenience and also by the Admin panel as a sanity-check.

Returns a $person ... I think.

PRIVATE: photos_flickr_config_page()

Displays the actual administrative configuration page. Byagh!

PRIVATE: photos_private_img()

Return an IMG tag for a photo.

 Arguments:
    $photo  =   $photo object -- defaults to
                $f->photos_getInfo($GLOBAL['photo_id'])
    $size   =   One of: square, thumbnail, small, medium, large,
                original

If we don't have a $photo available, we can:

 $f = global $f;
 $photo = $f->photos_getInfo($photo_id);
 photos_private_img($photo, 'medium');

PRIVATE: photos_private_getContext()

``MASTER'' function for: photos_(photo|photoset)_(next|prev)_(href|img|title)

 Arguments:
    $context    = (photo|photoset)
    $nl         = (next|prev)
    $attr       = (href|url|title)
    $photo_id   = photo ID for context
    $context_id = set ID for context
    $thumb_type = thumbnail type for img

We call it $context_id in the hope that we could one day give context for, say, tags ...

PRIVATE: whine()

Collect debug messages, emitting them in an apropriate manner, if appropriate.

OBSOLETED FUNCTIONS

Backwards-compatability is fun!

OBSOLETED: photos_index()

Obsoleted -- passes through to photos_photo_index().

OBSOLETED: photos_pageindex()

Obsoleted -- passes through to photos_photo_pageindex().

OBSOLETED: photos_index_href()

Obsoleted.

OBSOLETED: photos_photo_next_img()

Print IMG link for next photo in stream.

Accepts Flickr image size type as first argument: defaults to ``square''

OBSOLETED: photos_photo_prev_img()

Print IMG link for previous photo in stream.

Accepts Flickr image size type as first argument: defaults to ``square''

OBSOLETED: photos_photoset_url()

Print primary image URL of $photoset_id. (OBSOLETED)

Read More

Photos Flickr Resources
Photos Flickr
phpFlickr
Flickr API Service
Possibly-Related Posts

  • Pingback: dannyman.toldme.com / Photos Flickr 0.7()

  • Help!!!

    I don’t know enough coding to get this one on place – my photoalbum does not show the gif with my site name/home, and I just can’t figure out how to do it.

    I need to include the gif file somewhere down here, right? How is the code going to look like?

    /”>

    And how can I change the lay-out?

    Like for instance making the margin of the page larger (there is no margin right now)

    I could work it out in asp, but I know nothing of php…

    Can you pleeeeease help a desperate soul?

    Otherwise your album script is quite cool and easy!

    Thanks,
    /Suz