summaryrefslogtreecommitdiff
path: root/views/randimg.html.php
blob: b86420a17344ef49307b449542212b60eff2dc16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?php

if ( ! empty($item) ) {

	/**
 	* In some cases the proper URL path to the images on the disc
 	* will be virtualized via an Apache Alias definition, so grab
 	* that path here.
 	*/
	$virtpath =  $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']);

	// URL to Gallery3
	$g3path = "{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}";
	$link_path = $item->relative_url();
	$img_title = $item->title;

	switch (Input::instance()->get("size")) {
    	case "fullsize":
			$thumb_url = $item->file_url(true);
			break;
    	case "resize":
			$thumb_url = $item->resize_url(true);
			break;
    	case "thumb":
    	default:
			$thumb_url = $item->thumb_url(true);
	}

	if ( $width = Input::instance()->get("width") ) {
		$dimensions = "width: {$width}px;";
	}

	if ( $height = Input::instance()->get("height") ) {
		$dimensions .= "height: {$height}px;";
	}

	if ( $maxsize = Input::instance()->get("maxsize") ) {
		$dimensions = ( $item->width > $item->height ) ?
			"width: {$maxsize}px;" : "height: {$maxsize}px;";
	}

	$target = Input::instance()->get("target");
	$target = $target ? "target=\"$target\"" : "";

	echo <<<HTML
<div class="g-randimg">
	<a href="http://$g3path/$link_path" title="$img_title" $target>
		<img src="$thumb_url" style="border: thin solid black; $dimensions" alt="$img_title" />
	</a>
</div>
HTML;

}