-
Notifications
You must be signed in to change notification settings - Fork 6
Description
This is a rather simple change and it changes the following type of code parsing in descriptions:
[photo id=46 album=22 size=M html=true link=true]
Could be:
[photo album=22 size=M html=true link=true]
This would return the current thumbnail of album 22 instead of a specific photo. This is helpful because it means you don't need to change which photo you are loading if you change the thumbnail in the admin.
Why use this instead of [cat=]? Its because that tag does not have the provisions for html=false and link=false. That's extremely useful when using the AdditionalPages plugin, where you may have created your own links to albums.
Code changed in functions.inc.php around lines 97-120.
Find:
// check picture id
if (empty($params['id'])) return 'missing picture id';
Replace with:
// check picture id
if (empty($params['id']) && empty($params['album'])) return 'missing picture id';
Find:
// get picture
$query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = '.$params['id'].';';
$result = pwg_query($query);
Replace with:
if(!empty($params['id'])){
// get picture from id
$query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = '.$params['id'].';';
$result = pwg_query($query);
}elseif(!empty($params['album'])){
// get picture from album
$query = 'SELECT i.* FROM ' . IMAGES_TABLE . ' i, '.CATEGORIES_TABLE.' c WHERE c.id = '.$params['album'].' AND c.representative_picture_id IS NOT null AND c.representative_picture_id = i.id;';
$result = pwg_query($query);
}
That should pull the image that is the current thumbnail for the album, which can return the URL of the image by using the photo tag instead of the cat tag.
Edit: Testing and works!