added album functions. fixes #16

This commit is contained in:
Christian Haschek
2016-10-22 20:14:38 +02:00
parent 5765f3c0e4
commit f830d6266b
4 changed files with 88 additions and 0 deletions

View File

@@ -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/

View File

@@ -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.='<a href="/'.$filters.$hash.'"><img src="/'.$size.$forcesize.$filters.$hash.'" /></a>';
}
if($data['embed']===true)
include (ROOT . DS . 'template_album_embed.php');
else
include (ROOT . DS . 'template_album.php');
}
function renderImage($data)
{

View File

@@ -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))

44
template_album_embed.php Normal file
View File

@@ -0,0 +1,44 @@
<!DOCTYPE html>
<!--[if IEMobile 7 ]> <html class="no-js iem7"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Album - <?php echo (defined('TITLE')?TITLE:'PictShare image hosting'); ?></title>
<meta name="description" content="">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="cleartype" content="on">
<meta name="description" content="Free image sharing, linking and tracking">
<meta name="keywords" content="image, share, hosting, free">
<meta name="robots" content="index, follow">
<meta name="copyright" content="Haschek Solutions">
<meta name="language" content="EN,DE">
<meta name="author" content="Haschek Solutions">
<meta name="distribution" content="global">
<meta name="rating" content="general">
<style type="text/css">
body {
background: none transparent;
}
img {
<?php
if($data['responsive']===true)
echo ' display: block;
max-width: 100%;
height: auto;
padding-bottom:10px;';
else
echo 'padding:7px;';
?>
}
</style>
</HEAD>
<BODY>
<?php echo $content?>
</BODY>
</HTML>