-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
42 lines (41 loc) · 1.51 KB
/
functions.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
<?php
/*
* Thumb
* Version 1.0
* @author: Alexander Conroy
* @blog: http://www.geilt.com
* @website: http://www.esotech.org
* @email: [email protected]
*
* Insert the following code into your Wordpress theme functions.php
* Make sure that your timthumb cache folder is set to 777 and is in the includes folder of your theme.
*
* Allows you to use thumb() throughout your templates with options
* $args = array of values to pass to timthumb.
* License: GPLv3+
* Use it as you like, fork it, or whatever. Give credit if you can.
*/
$thumb = get_template_directory_uri() . "/includes/timthumb.php?";
if(!function_exists( 'get_thumb' ) ):
function get_thumb( $args = array(), $echo = false) {
global $thumb;
if( empty($args['src']) ):
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
$args['src'] = $thumbnail[0];
if( empty( $args['src'] ) && $args['placeholder'] !== 'disable' ):
$args['src'] = "http://placehold.it/" . ( isset($args['w']) ? $args['w'] : "150" ) . "x" . ( isset($args['h']) ? $args['h'] : "150" );
endif;
endif;
if( $echo ):
echo $thumb . http_build_query($args);
return;
else:
return $thumb . http_build_query($args);
endif;
}
endif;
if(!function_exists( 'the_thumb' ) ):
function the_thumb( $args = array()) {
get_thumb($args, true);
}
endif;