GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b76a31...90d510 )
by Brad
03:15
created

FooGallery_Thumbnails::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * FooGallery Thumbnail Resizing class
4
 */
5
6
if ( !class_exists( 'FooGallery_Thumbnails' ) ) {
7
8
	class FooGallery_Thumbnails {
9
10
		function __construct() {
11
			//generate thumbs using WPThumb
12
			add_filter( 'foogallery_attachment_resize_thumbnail', array( $this, 'resize' ), 10, 3 );
13
		}
14
15
		function resize( $original_image_src, $args, $thumbnail_object ) {
16
17
			$arg_defaults = array(
18
				'width'                   => 0,
19
				'height'                  => 0,
20
				'crop'                    => true,
21
				'jpeg_quality'            => foogallery_thumbnail_jpeg_quality(),
22
				'thumb_resize_animations' => foogallery_get_setting( 'thumb_resize_animations' )
23
			);
24
25
			$args = wp_parse_args( $args, $arg_defaults );
26
27
			if ( 'on' === foogallery_get_setting( 'use_original_thumbs' ) ) {
28
				$width  = (int)$args['width'];
29
				$height = (int)$args['height'];
30
				$crop   = (bool)$args['crop'];
31
32
				//check if we are trying to get back the default thumbnail that we already have
33
				if ( $thumbnail_object->ID > 0 && $width == get_option( 'thumbnail_size_w' ) && $height == get_option( 'thumbnail_size_h' ) && $crop == get_option( 'thumbnail_crop' ) ) {
34
					$thumbnail_attributes = wp_get_attachment_image_src( $thumbnail_object->ID );
35
36
					return $thumbnail_attributes[0];
37
				}
38
			}
39
40
			if ( $thumbnail_object->ID > 0 ) {
41
				$crop_from_position = get_post_meta( $thumbnail_object->ID, 'wpthumb_crop_pos', true );
42
43
				if ( !empty( $crop_from_position ) ) {
44
					$args['crop_from_position'] = $crop_from_position;
45
				}
46
			}
47
48
49
			return wpthumb( $original_image_src, $args );
50
		}
51
	}
52
}
53