forked from setola/Wordpress-Theme-Utils-Classes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MinigalleryThumbsLinkToBig.class.php
86 lines (77 loc) · 2.39 KB
/
MinigalleryThumbsLinkToBig.class.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* storest MinigalleryThumbsLinkToBig class definition
*/
/**
* Generates a list of thumbnail each one is an anchor
* to the image with 'full' media dimensions.
* By default loads FancyBox so to have an eye candy popup effect.
* @author etessore
* @version 1.0.1
* @package classes
*/
class MinigalleryThumbsLinkToBig extends GalleryHelper{
/**
* @var string the substitution template
*/
public $tpl;
/**
* @var string stores the media dimension for the big image
*/
public $media_dimension_big;
/**
* Initializes the minigallery
*/
public function __construct(){
$this
->set_template('%prev%<div class="images-container">%list%</div>%next%')
->set_wp_media_dimension_big();
}
/**
* Sets the media dimension for the big image
* @param string $dimension the media dimension name
* @return MinigalleryThumbsLinkToBig $this for chainability
*/
public function set_wp_media_dimension_big($dimension='full'){
$this->media_dimension_big = $dimension;
return $this;
}
/**
* (non-PHPdoc)
* @see GalleryHelper::get_markup()
*/
public function get_markup(){
$toret = '';
if(count($this->images)>0){
$subs = new SubstitutionTemplate();
$subs
->set_tpl($this->tpl)
->set_markup('prev', HtmlHelper::anchor('javascript:;', '<', array('class'=>'prev control')))
->set_markup('next', HtmlHelper::anchor('javascript:;', '>', array('class'=>'next control')));
ThemeHelpers::load_js('minigallery-thumbs-link-to-big');
ThemeHelpers::load_css('jquery-fancybox');
foreach($this->images as $index => $image){
$image_big = wp_get_attachment_image_src($this->get_image_id($index), $this->media_dimension_big);
$image_small = wp_get_attachment_image_src($this->get_image_id($index), $this->media_dimension);
$toret .= HtmlHelper::anchor(
$image_big[0],
HtmlHelper::image(
$this->get_image_src($index),
array(
'alt' => $this->get_image_alt($index),
'title' => $this->get_image_description($index),
'data-caption' => $this->get_image_caption($index)
)
),
array(
'class' => 'fancybox',
'rel' => 'group',
'title' => $this->get_image_caption($index)
)
);
}
$toret = $subs->set_markup('list', $toret)->replace_markup();
}
return $toret;
}
}