From f830d6266b8e7f1f4735f5a40128c5a46cde0b50 Mon Sep 17 00:00:00 2001 From: Christian Haschek Date: Sat, 22 Oct 2016 20:14:38 +0200 Subject: [PATCH] added album functions. fixes #16 --- README.md | 7 +++++++ inc/core.php | 23 ++++++++++++++++++++ models/pictsharemodel.php | 14 +++++++++++++ template_album_embed.php | 44 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 template_album_embed.php diff --git a/README.md b/README.md index c5a06fa..62bef75 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ UPDATES - Nov. 06: Master delete code. One code to delete them all - Nov. 01: [Restricted uploads and option-use](#restriction-settings) - Oct. 30: [Rotations and filters](#smart-query-system) +- Oct. 10: [Album functionality](#smart-query-system) finally ready ## Why would I want to host my own images? If you own a server (even an home server) you can host your own PictShare instance so you have full control over your content and can delete images hasslefree. @@ -99,6 +100,12 @@ If there is some option that's not recognized by PictShare it's simply ignored, **Resizing** | | | <width>**x**<height> | -none- | https://pictshare.net/20x20/b260e36b60.jpg | ![Resized](https://pictshare.net/20x20/b260e36b60.jpg) forcesize | -none- | https://pictshare.net/100x400/forcesize/b260e36b60.jpg | ![Forced size](https://pictshare.net/100x400/forcesize/b260e36b60.jpg) +**Albums** | | | +just add multiple image hashes | -none- | https://www.pictshare.net/b260e36b60.jpg/32c9cf77c5.jpg/163484b6b1.jpg | Takes the **images** you put in the URL and makes an album out of them +embed | -none- | https://www.pictshare.net/b260e36b60.jpg/32c9cf77c5.jpg/163484b6b1.jpg/embed | Renders the album without CSS and with transparent background so you can embed them easily +responsive | -none- | https://www.pictshare.net/b260e36b60.jpg/32c9cf77c5.jpg/163484b6b1.jpg/responsive | Renders all images responsive (max-width 100%) according to screen size +<width>**x**<height> | -none- | https://www.pictshare.net/b260e36b60.jpg/32c9cf77c5.jpg/163484b6b1.jpg/150x150 | Sets the size for the thumbnails in the album +forcesize | -none- | https://www.pictshare.net/b260e36b60.jpg/32c9cf77c5.jpg/163484b6b1.jpg/100x300/forcesize | Forces thumbnail sizes to the values you provided **GIF to mp4** | | | mp4 | -none- | https://www.pictshare.net/mp4/102687fe65.gif | Converts gif to mp4 and displays as that. Note that you can't include that mp4 in an img tag raw | -none- | https://www.pictshare.net/mp4/raw/102687fe65.gif | Renders the converted mp4 directly. Use with /mp4/ diff --git a/inc/core.php b/inc/core.php index b772399..6b6f195 100644 --- a/inc/core.php +++ b/inc/core.php @@ -106,11 +106,34 @@ function whatToDo($url) render($vars); } + else if($data['album']) + renderAlbum($data); else renderImage($data); } +function renderAlbum($data) +{ + if($data['filter']) + $filters = implode('/',$data['filter']).'/'; + if($data['size']) + $size = $data['size'].'/'; + else if(!$data['responsive']) + $size = '300x300/'; + + $forcesize = ($data['forcesize']?'forcesize/':''); + + foreach($data['album'] as $hash) + { + $content.=''; + } + + if($data['embed']===true) + include (ROOT . DS . 'template_album_embed.php'); + else + include (ROOT . DS . 'template_album.php'); +} function renderImage($data) { diff --git a/models/pictsharemodel.php b/models/pictsharemodel.php index b7e0601..fa8d16f 100644 --- a/models/pictsharemodel.php +++ b/models/pictsharemodel.php @@ -70,11 +70,25 @@ class PictshareModel extends Model $data['changecode'] = substr($el,11); if($this->isImage($el)) + { + //if there are mor than one hashes in url + //make an album from them + if($data['hash']) + { + if(!$data['album']) + $data['album'][] = $data['hash']; + $data['album'][] = $el; + } $data['hash']=$el; + } else if($el=='mp4' || $el=='raw' || $el=='preview' || $el=='webm' || $el=='ogg') $data[$el] = 1; else if($this->isSize($el)) $data['size'] = $el; + else if($el=='embed') + $data['embed'] = true; + else if($el=='responsive') + $data['responsive'] = true; else if($this->isRotation($el)) $data['rotate'] = $el; else if($this->isFilter($el)) diff --git a/template_album_embed.php b/template_album_embed.php new file mode 100644 index 0000000..351480c --- /dev/null +++ b/template_album_embed.php @@ -0,0 +1,44 @@ + + + + + + Album - <?php echo (defined('TITLE')?TITLE:'PictShare image hosting'); ?> + + + + + + + + + + + + + + + + + + + + +