* @return string
*/
protected function add_class_to_img_tag( $image, $class )
{
if( false === strpos( $image, 'class=' ) )
{
$image = str_replace( '
base_images;
foreach( $all as $sizes )
{
if( ! in_array( $sizes['width'], $widths ) )
{
$widths[] = $sizes['width'];
}
}
sort( $widths );
$groups = array();
while( count( $widths ) > 0 )
{
$current_width = array_shift( $widths );
do
{
$found = false;
$height_key = '';
foreach( $all as $name => $sizes )
{
if( $sizes['width'] == $current_width )
{
$height_key = $sizes['height'];
$group_key = $current_width . '*' . $height_key;
$groups[ $group_key ][ $name ] = $sizes;
unset( $all[ $name ] );
$found = true;
break;
}
}
if( ! $found )
{
break;
}
/**
* Check remaining for same aspect ratio
*/
foreach( $all as $name => $sizes )
{
if( wp_image_matches_ratio( $current_width, $height_key, $sizes['width'], $sizes['height'] ) )
{
$groups[ $group_key ][ $name ] = $sizes;
unset( $all[ $name ] );
}
}
} while ( $found );
}
$this->size_groups = array();
foreach( $groups as $group => $images )
{
$widths = array();
foreach( $images as $image )
{
if( ! in_array( $image['width'], $widths ) )
{
$widths[] = $image['width'];
}
}
sort( $widths );
while( count( $widths ) > 0 )
{
$current_width = array_shift( $widths );
foreach( $images as $name => $sizes )
{
if( $sizes['width'] == $current_width )
{
$this->size_groups[ $group ][ $name ] = $sizes;
unset( $images[ $name ] );
}
}
}
}
}
/**
* Prepare overview of used image sizes for theme options page
*
* @since 4.7.5.1
* @return string
*/
public function options_page_overview()
{
$html = '';
foreach( $this->size_groups as $size_group => $sizes )
{
$html .= '
' . $this->get_group_headline( $size_group ) . '
';
$html .= '';
foreach( $sizes as $key => $image )
{
$info = $image['width'] . '*' . $image['height'];
if( isset( $image['crop'] ) && true === $image['crop'] )
{
$info .= ' ' . __( '(cropped)', 'avia_framework' );
}
$info .= ' - ' . $this->get_image_key_info( $key );
$html .= '- ' . $info . '
';
}
$html .= '
';
}
return $html;
}
/**
* Returns the string for the group headline.
* Calculates the aspect ratio or only width/height if one value is 0
*
* @since 4.7.5.1
* @param string $group
* @return string
*/
protected function get_group_headline( $group )
{
$headline = '';
$sizes = explode( '*', $group );
$w = isset( $sizes[0] ) ? (int) $sizes[0] : 0;
$h = isset( $sizes[1] ) ? (int) $sizes[1] : 0;
if( 0 == $h )
{
$headline .= __( 'Images keeping original aspect ratio', 'avia_framework' );
}
else if ( 0 == $w )
{
$headline .= __( 'Images keeping original aspect ratio', 'avia_framework' );
}
else
{
$gcd = $this->greatest_common_divisor( $w, $h );
$w = (int) ( $w / $gcd );
$h = (int) ( $h / $gcd );
$headline .= sprintf( __( 'Images aspect ratio: %d : %d', 'avia_framework' ), $w, $h );
}
/**
*
* @since 4.7.5.1
* @param string $headline
* @param string $group
* @return string
*/
return apply_filters( 'avf_admin_image_group_headline', $headline, $group );
}
/**
* Return readable info for an image size key for options page
*
* @since 4.7.5.1
* @param string $image_key
* @return string
*/
protected function get_image_key_info( $image_key )
{
$info = '';
$info .= ( array_key_exists( $image_key, $this->readable_img_sizes ) ) ? $this->readable_img_sizes[ $image_key ] : $image_key;
$info .= ' (';
if( array_key_exists( $image_key, $this->theme_images ) )
{
$info .= __( 'added by theme', 'avia_framework' );
}
else if( array_key_exists( $image_key, $this->plugin_images ) )
{
$info .= __( 'added by a plugin', 'avia_framework' );
}
else if( array_key_exists( $image_key, $this->wp_default_images ) )
{
$info .= __( 'WP default size', 'avia_framework' );
}
else
{
$info .= __( 'unknown', 'avia_framework' );
}
$info .= ')';
/**
*
* @since 4.7.5.1
* @param string $info
* @param string $image_key
* @return string
*/
return apply_filters( 'avf_admin_image_key_info', $info, $image_key );
}
/**
* Calculates the value based on https://en.wikipedia.org/wiki/Greatest_common_divisor - euclid's algorithm
*
* @since 4.7.5.1
* @param int $a
* @param int $b
* @return int
*/
protected function greatest_common_divisor( $a, $b )
{
if( 0 == $a )
{
return abs( $b );
}
if( 0 == $b )
{
return abs( $a );
}
if( $a < $b )
{
$h = $a;
$a = $b;
$b = $h;
}
do
{
$h = $a % $b;
$a = $b;
$b = $h;
} while ( $b != 0 );
return abs( $a );
}
}
/**
* Returns the main instance of av_responsive_images to prevent the need to use globals
*
* @since 4.7.5.1
* @param array|null $config
* @return av_responsive_images
*/
function Av_Responsive_Images( $config = array() )
{
return av_responsive_images::instance( $config );
}
}
Fatal error: Uncaught Error: Call to undefined function Av_Responsive_Images() in /home/payon/public_html/wp-content/themes/enfold/functions.php:240
Stack trace:
#0 /home/payon/public_html/wp-settings.php(591): include()
#1 /home/payon/public_html/wp-config.php(92): require_once('/home/payon/pub...')
#2 /home/payon/public_html/wp-load.php(50): require_once('/home/payon/pub...')
#3 /home/payon/public_html/wp-blog-header.php(13): require_once('/home/payon/pub...')
#4 /home/payon/public_html/index.php(17): require('/home/payon/pub...')
#5 {main}
thrown in /home/payon/public_html/wp-content/themes/enfold/functions.php on line 240