Willkommen auf der privaten Homepage von Johannes Jarolim, Salzburg, Österreich

Welcome to the private homepage of Johannes Jarolim, Salzburg, Austria, Europe.

This is a YAPB post

31. May 2007, 22:05

YAPB Template Functions

232

Since YAPB 1.5 you may use the following template functions:

yapb_is_photoblog_post

Function returns wheter this post is a photoblog post or not.

No Parameters
Returns boolean

Sample usage:

<?php if (yapb_is_photoblog_post()): ?>HEHEHE<?php endif ?>

yapb_get_image

Function returns an image tag according to the given parameters

Parameters:

  1. string $before HTML to be rendered before the image
  2. array $parameters Additional IMG Attributes except src, width and height
  3. string $after HTML to be rendered after the image

Returns string containing the image tag

Sample Usage:

<?php echo yapb_get_image('<div>', array('alt' => 'This is an image'), '</div>'); ?>

yapb_image

Same as yapb_get_image (See above) - It just prints out the result instead of returning it

Parameters: Same as yapb_get_image

Sample Usage:

<?php yapb_image('<div>', array('alt' => 'This is an image'), '</div>'); ?>

yapb_get_thumbnail

Function returns an thumbnail image tag according to the given parameters

Parameters:

  1. string $before HTML to be rendered before the thumbnail
  2. array $parameters Additional IMG Attributes except src, width and height
  3. string $after HTML to be rendered after the thumbnail
  4. array $phpThumbConfiguration The phpThumb configuration
  5. string $class Additional CSS Class of the image

Returns string containing the image tag

Sample Usage:

 <?php echo yapb_get_thumbnail('<div>', array('alt' => 'This is a thumbnail', 'rel' => 'lightbox'), '</div>', array('w=200', 'q=90'), 'thumbnail'); ?>

As you can see above, this code sample is also an example on how to include the lightbox.js script.

yapb_thumbnail

Same as yapb_get_thumbnail (See above) - It just prints out the result instead of returning it

Parameters: Same as yapb_get_thumbnail

Sample Usage:

<?php yapb_thumbnail('<div>', array('alt' => 'This is a thumbnail'), '</div>', array('w=200', 'q=90'), 'thumbnail'); ?>

yapb_get_exif

functions returns a list of the exif tokens if available

Parameters:

  1. boolean $flagUnfiltered No EXIF-tag filtering if true - Return all EXIF tokens

Returns assoziative array containing all (filtered) EXIF tokens

Sample Usage:

<?php $theWonderfulExif = yapb_get_exif() ?>

yapb_exif

literally the same as the function above - It just prints out the exif tags and gives you some parameters so you can customize the output.

Parameters:

  • string $liClass CSS class of the li tags
  • string $keyValueSeparator HTML between EXIF key and EXIF value
  • string $htmlBeforeKey HTML to be rendered before the EXIF key
  • string $htmlAfterKey HTML to be rendered after the EXIF key
  • string $htmlBeforeValue HTML to be rendered before the EXIF value
  • string $htmlAfterValue HTML to be rendered after the EXIF value
  • boolean $flagUnfiltered No EXIF-tag filtering if true - Return all EXIF tokens

Sample Usage:

<h3>EXIF</h3><ul><?php yapb_exif('exiftag', ':', '<strong>', '</strong>', '<i>', '</i>') ?></ul>

yapb_get_alternative_image_formats

Returns a listitems with links to alternatively provided image sizes. It will only return image sizes lower or equal that the original uploaded file. The array availableSizes contains should contain a list of all sizes to be provided: The number gets mapped to the longer side of the image.

Parameters:

  1. array $availableSizes An array containing all max. sizes to be made available

Returns string containing some li’s

Sample Usage:

<h3>Alternative Image Formats</h3><ul><?php echo yapb_get_alternative_image_formats(array(1600, 1024, 800, 640, 320)) ?></ul>

yapb_alternative_image_formats

Basicly the same as above - Just prints out the result

Parameters: Same as above

Sample Usage:

 <h3>Alternative Image Formats</h3><ul><?php yapb_alternative_image_formats(array(1600, 1024, 800, 640, 320)) ?></ul>

This entry was posted on Thursday 31. May 2007 at 22:05.

16 Comments »

2007-06-06 00:24:53
Comment by Queso

How can I set the large image inside the post to be 790px instead of 460?
this is a great plugin!

 
2007-08-19 01:52:23
Comment by Mac [unlesbar]

Was mich davon abhält, die Funktion yapb_thumbnail() zu nutzen ist der Umstand, dass ich einen Alternativtext, sowie einen Titel angeben können muss. Vielleicht könntest du den entsprechenden 2. Parameter dahingehend abändern, dass bei Übergabe eines Arrays (etwa 'alt'=>'...', 'title'=>'...') beides angegeben werden kann. Dann musst du die API nicht wieder umkrempeln. Gleiches gilt für die Übergabe einer ID.
Der Ansatz gefällt mir ansonsten.

 
2007-12-16 23:31:24
Comment by Cyclefitness

Two questions:

1. Is this updated for the latest release of WordPress?
2. Are there instructions for what to do with these functions?

2007-12-17 18:36:54
Comment by Johannes

1. yes
2. You can edit your themes template files so the use those functions to display yapb images. More info on the adapt themes manually pages.

 
 
2007-12-17 20:44:43
Comment by Cyclefitness

Thanks, Johannes. My blog is here: http://www.debbiesilbert.com/photoblog. I want a way to add thumbnails on the sidebar. Is that something I can do with one of these functions? If so, do I need to do anything other than copy the function over to my site and put it on the correct page?

2008-01-31 14:32:19
Comment by Johannes

Have a look at the sidebar widget provided by YAPB ;-)

 
 
2008-01-31 13:36:37
Comment by Raicho Nikolov

I have had problems with the sample codes above. You probably have to put it in tags or something like this, because when I copy it it is reformatted and the single quotes are very strange and need to be edited(if they are not edited PHP complains).

Thank you for the nice plugin! Keep walking :)

2008-01-31 14:33:17
Comment by Johannes

Thanks - i didn’t mention it. I’ll have a look how to disable that WordPress feature ;-)

 
2008-01-31 14:58:40
Comment by Johannes

Corrected! Thanks again for the tip - If someone has this problem too, just google for “disable wordpress smart quotes” - i used the following plugin: http://www.planetmike.com/jour.....odequotes/

 
 
2008-02-05 23:08:02
Comment by Dario

Hi! Can you help me with this problem?…
http://johannes.jarolim.com/ya.....hp?tid=552

 
2008-02-07 01:06:29
Comment by Jorge Otero

yapb_thumbnail and yapb_get_thumbnail aren’t passing the class and title parameters. They seem to be ignored. Is that so?

2008-02-07 08:59:00
Comment by Johannes

Yup a bug. Released YAPB 1.7.3 some minutes ago. Thanks for the report!

Happy photoblogging!

 
 
2008-02-09 14:47:21
Comment by Mackan

I gor this error:

Warning: Invalid argument supplied for foreach() in /foo/bar/wp-content/plugins/yet-another-photoblog/lib/YapbImage.class.php on line 645

with this tag:

<?php echo yapb_get_thumbnail(”, ‘This is a thumbnail’, ”, array(’w=200′, ‘q=90′), ‘thumbnail’); ?>

Using YAPB 1.7.3 with WP 2.3.3

2008-02-10 18:12:34
Comment by Johannes

Ah - This is a bug in the documentation and will be fixed in some minutes. The second parameter of the function is an array containing additional attributes of the img tag - array('alt' => 'Wonderful image', 'border' => '0') for example.

 
2008-02-10 18:23:13
Comment by Johannes

Fixed in the documentation - Thanks for the feedback!

 
 
2008-02-10 23:24:23
Pingback by hkim » photo » Macro

[...] Jan 31st, 2004 • Category: photo YAPB 테스트. 보다 ìž?세한 사용법ì?„ 보려면 how to use yapb code in template ì?„ 방문할 [...]

 

Respond now

Name (required)
E-mail (required - never shown publicly)
Website
Spam protection: Sum of 14 + 16 ?
Your Comment (smaller size | larger size)