| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 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 MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/bb-plugin/classes/ |
Upload File : |
<?php
/**
* Helper class for working with photos.
*
* @since 1.0
*/
final class FLBuilderPhoto {
/**
* Returns an array of data for sizes that are
* defined for WordPress images.
*
* @since 1.0
* @return array
*/
static public function sizes()
{
global $_wp_additional_image_sizes;
$sizes = array();
foreach(get_intermediate_image_sizes() as $size) {
// Hidden size added in 4.4 for responsive images. We don't need it.
if ( 'medium_large' == $size ) {
continue;
}
$sizes[$size] = array(0, 0);
if(in_array($size, array('thumbnail', 'medium', 'large'))) {
$sizes[$size][0] = get_option($size . '_size_w');
$sizes[$size][1] = get_option($size . '_size_h');
}
else if(isset($_wp_additional_image_sizes) && isset($_wp_additional_image_sizes[$size])) {
$sizes[$size] = array(
$_wp_additional_image_sizes[$size]['width'],
$_wp_additional_image_sizes[$size]['height']
);
}
}
return $sizes;
}
/**
* Returns an object with data for an attachment using
* wp_prepare_attachment_for_js based on the provided id.
*
* @since 1.0
* @param string $id The attachment id.
* @return object
*/
static public function get_attachment_data($id)
{
$data = wp_prepare_attachment_for_js($id);
$data['url'] = str_replace(home_url(),'',$data['url']);
$data['link'] = str_replace(home_url(),'',$data['link']);
$data['icon'] = str_replace(home_url(),'',$data['icon']);
$data['editLink'] = str_replace(home_url(),'',$data['editLink']);
$data['sizes']['thumbnail']['url'] = str_replace(home_url(),'',$data['sizes']['thumbnail']['url']);
$data['sizes']['full']['url'] = str_replace(home_url(),'',$data['sizes']['full']['url']);
if(gettype($data) == 'array') {
return json_decode(json_encode($data));
}
return $data;
}
/**
* Renders the thumb URL for a photo object.
*
* @since 1.0
* @param object $photo An object with photo data.
* @return void
*/
static public function get_thumb($photo)
{
if ( empty( $photo ) ) {
echo FL_BUILDER_URL . 'img/spacer.png';
}
else if ( ! isset( $photo->sizes ) ) {
echo $photo->url;
}
else if ( ! empty( $photo->sizes->thumbnail ) ) {
echo $photo->sizes->thumbnail->url;
}
else {
echo $photo->sizes->full->url;
}
}
/**
* Renders the options for a photo select field.
*
* @since 1.0
* @param string $selected The selected URL.
* @param object $photo An object with photo data.
* @return void
*/
static public function get_src_options($selected, $photo)
{
if ( ! isset( $photo->sizes ) ) {
echo '<option value="' . $photo->url . '" selected="selected">' . _x( 'Full Size', 'Image size.', 'fl-builder' ) . '</option>';
}
else {
$titles = array(
'full' => _x( 'Full Size', 'Image size.', 'fl-builder' ),
'large' => _x( 'Large', 'Image size.', 'fl-builder' ),
'medium' => _x( 'Medium', 'Image size.', 'fl-builder' ),
'thumbnail' => _x( 'Thumbnail', 'Image size.', 'fl-builder' )
);
foreach($photo->sizes as $key => $val) {
if(!isset($titles[$key])) {
$titles[$key] = ucwords(str_replace(array('_', '-'), ' ', $key));
}
echo '<option value="' . $val->url . '" ' . selected($selected, $val->url) . '>' . $titles[$key] . ' - ' . $val->width . ' x ' . $val->height . '</option>';
}
}
}
}