model;
$value = array_key_exists( 'value', $model ) ? $model['value'] : array();
$main_settings = $value['main_settings'];
//$borders_corners_settings = $value['borders_corners'];
if ( !function_exists( 'Nimble\remove_attachment_image_style_attr' ) ) {
function remove_attachment_image_style_attr( $attr ) {
if ( is_array($attr) && isset($attr['style']) ) {
unset($attr['style']);
}
return $attr;
}
}
if ( !function_exists( 'Nimble\sek_get_img_module_img_html') ) {
function sek_get_img_module_img_html( $value, $for_mobile = false, $img = null, $img_size = null ) {
$img = !is_null($img) ? $img : $value['img'];
$img_size = !is_null($img_size) ? $img_size : $value['img-size'];
$use_post_thumbnail = !empty( $value['use-post-thumb'] ) && sek_is_checked( $value['use-post-thumb'] );
if ( $use_post_thumbnail ) {
$current_post_id = sek_get_post_id_on_front_and_when_customizing();
$is_attachment = is_attachment();
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && skp_is_customizing() ) {
$is_attachment = sek_get_posted_query_param_when_customizing( 'is_attachment' );
}
if ( $is_attachment ) {
$img = $current_post_id;
} else {
$img = ( has_post_thumbnail( $current_post_id ) ) ? get_post_thumbnail_id( $current_post_id ) : $img;
}
}
$img_figure_classes = '';
//visual effect classes
if ( true === sek_booleanize_checkbox_val( $value['use_box_shadow'] ) ) {
$img_figure_classes = ' box-shadow';
}
if ( 'none' !== $value['img_hover_effect']) {
$img_figure_classes .= " sek-hover-effect-" . $value['img_hover_effect'];
}
$img_figure_classes .= $for_mobile ? " sek-is-mobile-logo" : " sek-img";
if ( true === sek_booleanize_checkbox_val( $value['use_custom_height'] ) ) {
$img_figure_classes .= " has-custom-height";
}
$html = '';
if ( is_int( $img ) ) {
// Nov 2020 : removes any additional styles added by a theme ( Twenty Twenty one ) or a plugin to the image
add_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
$html = wp_get_attachment_image( $img, empty( $img_size ) ? 'large' : $img_size);
remove_filter( 'wp_get_attachment_image_attributes', '\Nimble\sek_remove_image_style_attr', 999 );
} else if ( !empty( $img ) && is_string( $img ) ) {
// the default img is excluded from the smart loading parsing @see nimble_regex_callback()
// => this is needed because this image has no specific dimensions set. And therefore can create false javascript computations of other element's distance to top on page load.
// in particular when calculting if is_visible() to decide if we smart load.
if ( false !== wp_http_validate_url( $img ) ) {
$html = sprintf( '', esc_url( $img ) );
}
} else {
//falls back on an icon if previewing
if ( skp_is_customizing() ) {
$html = sprintf('