| Server IP : 38.190.208.107 / Your IP : 216.73.216.74 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/blocksy/inc/components/media/ |
Upload File : |
<?php
/**
* Generate an image container based on image URL.
*
* @param string $image_src URL to the image.
* @param array $args various params that the function accepts.
*/
if (! function_exists('blocksy_simple_image')) {
function blocksy_simple_image($image_src, $args = []) {
$args = wp_parse_args(
$args,
[
'ratio' => '1/1',
'class' => '',
'aspect_ratio' => true,
'tag_name' => 'div',
'html_atts' => [],
'img_atts' => [],
'inner_content' => '',
'lazyload' => true,
'size' => 'medium',
'suffix' => '',
'has_default_alt' => true,
'has_default_class' => true,
]
);
$original = '';
if ($args['has_default_class']) {
$original = 'ct-media-container';
}
if (! empty($args['suffix'])) {
$original .= '-' . $args['suffix'];
}
if ($args['aspect_ratio']) {
$args['img_atts']['style'] = isset($args['img_atts']['style'])
? $args['img_atts']['style'] . ';'
: '';
$args['img_atts']['style'] .= blocksy_generate_ratio($args['ratio']);
}
$other_img_atts = '';
if (! isset($args['img_atts']['alt']) && $args['has_default_alt']) {
$args['img_atts']['alt'] = __('Default image', 'blocksy');
}
foreach ($args['img_atts'] as $attr => $value) {
$other_img_atts .= $attr . '="' . $value . '" ';
}
if (! isset($args['html_atts']['class'])) {
$args['html_atts']['class'] = $original;
} else {
$args['html_atts']['class'] = join(' ', [$original, $args['html_atts']['class']]);
}
$image_content = blocksy_html_tag(
'img',
array_merge(
[
'src' => $image_src
],
$args['img_atts']
)
);
if (
wp_lazy_loading_enabled('img', 'blocksy_simple_image')
&&
false === strpos($image_content, ' loading=')
) {
if (function_exists('wp_img_tag_add_loading_optimization_attrs')) {
$image_content = wp_img_tag_add_loading_optimization_attrs(
$image_content,
'blocksy_simple_image'
);
} else {
$image_content = wp_img_tag_add_loading_attr(
$image_content,
'blocksy_simple_image'
);
}
}
return blocksy_html_tag(
$args['tag_name'],
$args['html_atts'],
$image_content . $args['inner_content']
);
}
}