55 'width' => $this->width,
56 'height' => $this->height,
58 'title' => $this->title,
59 'size' => $this->size,
61 'class' => $this->
class,
62 'getimagesize' =>
false,
63 'validate_src' =>
true 66 $atts = wp_parse_args( $atts, $defaults );
68 foreach( $atts as $key => $val ) {
72 $this->
class = !empty( $this->class ) ? esc_attr( implode( ' ', (array)$this->class ) ) : $this->class;
88 if ( !$this->validate_src ) {
return true; }
90 $info = pathinfo( $this->src );
92 $image_exts = self::get_image_extensions();
94 return isset( $info[
'extension'] ) && in_array( strtolower( $info[
'extension'] ), $image_exts);
110 $image_exts = apply_filters(
'gravityview_image_extensions', array(
'jpg',
'jpeg',
'jpe',
'gif',
'png',
'bmp',
'tif',
'tiff',
'ico',
'webp' ) );
112 return (array) $image_exts;
120 public function set_image_size( $string = NULL, $width = NULL, $height = NULL ) {
124 if ( empty( $width ) || empty( $height ) ) {
128 if ( empty( $string ) && !empty( $this->getimagesize ) ) {
130 $image_size = @getimagesize( $this->src );
133 if ( empty( $image_size[0] ) ) {
134 $image_size = @getimagesize( set_url_scheme( $this->src,
'http' ) );
137 if ( !empty( $image_size ) ) {
138 list( $width, $height ) = $image_size;
149 $image_sizes = apply_filters(
'gravityview_image_sizes', array(
150 'tiny' => array(
'width' => 40,
'height' => 30),
151 'small' => array(
'width' => 100,
'height' => 75),
152 'medium' => array(
'width' => 250,
'height' => 188),
153 'large' => array(
'width' => 448,
'height' => 336),
156 switch( $this->size ) {
158 extract($image_sizes[
'tiny']);
163 extract($image_sizes[
'small']);
167 extract($image_sizes[
'medium']);
171 extract($image_sizes[
'large']);
175 $width = !empty( $width ) ? intval( $width ) : intval( $this->width );
176 $height = !empty( $height ) ? intval( $height ) : intval( $this->height );
197 foreach ( array(
'width',
'height',
'alt',
'title',
'class' ) as $attr ) {
199 if ( empty( $this->{$attr} ) ) {
continue; }
201 $atts .= sprintf(
' %s="%s"', $attr, esc_attr( $this->{$attr} ) );
204 $html = sprintf(
'<img src="%s"%s />', esc_url_raw( $this->src ), $atts );
212 return apply_filters(
'gravityview_image_html', $html, $this );
Generic class for generating image tag.
html()
Return the HTML tag for the image.
__toString()
Handle being treated as a string by returning the HTML.
validate_image_src()
Verify that the src URL matches image patterns.
__construct( $atts=array())
set_image_size( $string=NULL, $width=NULL, $height=NULL)
Get default widths and heights for image size.
static get_image_extensions()
Returns an array of file extensions recognized by GravityView as images.