summaryrefslogtreecommitdiff
path: root/yarpp-template-custom-thumbnails.php
blob: 66cc103225fd1c2d03dd72c95cd6feff75e82627 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
 * RPP's built-in thumbnails template
 * customized by me
 * @since 4
 *
 * This template is used when you choose the built-in thumbnails option.
 * If you want to create a new template, look at yarpp-templates/yarpp-template-example.php as an example.
 * More information on the custom templates is available at http://mitcho.com/blog/projects/yarpp-3-templates/
 */


$__origin_title = get_the_title();

if ( !$this->diagnostic_using_thumbnails() )
	$this->set_option( 'manually_using_thumbnails', true );

$options = array( 'thumbnails_heading', 'thumbnails_default', 'no_results' );
extract( $this->parse_args( $args, $options ) );

// a little easter egg: if the default image URL is left blank,
// default to the theme's header image. (hopefully it has one)
if ( empty($thumbnails_default) )
	$thumbnails_default = get_header_image();

$dimensions = $this->thumbnail_dimensions();

$output .= '<h3>' . $thumbnails_heading . '</h3>' . "\n";

if (have_posts()) {
	$output .= '<div class="yarpp-thumbnails-horizontal">' . "\n";
	while (have_posts()) {
		the_post();

		$__get_the_title = get_the_title();

		$output .= "<a data-clean-title='".get_my_clean_title($__get_the_title)."' data-origin-post='".get_my_clean_title($__origin_title)."' class='yarpp-thumbnail' href='" . get_permalink() . "' title='" . the_title_attribute('echo=0') . "'>" . "\n";

// onclick='javascript:_paq.push([\"trackEvent\", \"related post\", \"" . get_my_clean_title($__get_the_title) . "\"]);'

		$post_thumbnail_html = '';
		if ( has_post_thumbnail() ) {
			if ( $this->diagnostic_generate_thumbnails() )
				$this->ensure_resized_post_thumbnail( get_the_ID(), $dimensions );
			$post_thumbnail_html = get_the_post_thumbnail( null, $dimensions['size'], array( 'class' => 'img-thumbnail') );

			/**
			 * replaces all images on fuselkönig.de by a image server, which croppes them nicely
			 */
			#$post_thumbnail_html = str_replace('https://www.fuselkoenig.de', 'https://www.fuselkoenig.de/crop?width=240&height=240&gravity=centre&url=https://www.fuselkoenig.de', $post_thumbnail_html);
			
			$post_thumbnail_html = str_replace('https://www.fuselkoenig.de', '/crop/240/240/centre', $post_thumbnail_html);
		}
		
		if ( trim($post_thumbnail_html) != '' )
			$output .= $post_thumbnail_html;
		else
			$output .= '<span class="yarpp-thumbnail-default"><img class="img-thumbnail" src="' . esc_url($thumbnails_default) . '"/></span>';

		#$output .= '<span class="yarpp-thumbnail-title">' . str_replace('Im Test: ', '', get_the_title()) . '</span>';
		$output .= '<span class="yarpp-thumbnail-title">' . get_my_clean_title( $__get_the_title ) . '</span>';
		$output .= '</a>' . "\n";

	}
	$output .= "</div>\n";
} else {
	$output .= $no_results;
}

$this->enqueue_thumbnails( $dimensions );