Exemplo n.º 1
0
 function get_image_sizes($size = '')
 {
     global $_wp_additional_image_sizes;
     $sizes = array();
     $get_intermediate_image_sizes = get_intermediate_image_sizes();
     // Create the full array with sizes and crop info
     foreach ($get_intermediate_image_sizes as $_size) {
         if (in_array($_size, array('thumbnail', 'medium', 'large'))) {
             $sizes[$_size]['width'] = get_option($_size . '_size_w');
             $sizes[$_size]['height'] = get_option($_size . '_size_h');
             $sizes[$_size]['crop'] = (bool) get_option($_size . '_crop');
         } elseif (isset($_wp_additional_image_sizes[$_size])) {
             $sizes[$_size] = array('width' => $_wp_additional_image_sizes[$_size]['width'], 'height' => $_wp_additional_image_sizes[$_size]['height'], 'crop' => $_wp_additional_image_sizes[$_size]['crop']);
         }
     }
     // Get only 1 size if found
     if ($size) {
         if (isset($sizes[$size])) {
             return $sizes[$size];
         } else {
             return false;
         }
     }
     return $sizes;
 }
Exemplo n.º 2
0
 function groundup_image_suffix($image)
 {
     // Split the $image path into directory/extension/name
     $info = pathinfo($image);
     $dir = $info['dirname'] . '/';
     $ext = '.' . $info['extension'];
     $file_name = wp_basename($image, "{$ext}");
     $image_name = substr($file_name, 0, strrpos($file_name, '-'));
     // Get image information
     $img = wp_get_image_editor($image);
     // Get image size, width and height
     $img_size = $img->get_size();
     // Get new image suffix by comparing image sizes
     $image_sizes = get_intermediate_image_sizes();
     foreach ($image_sizes as $size) {
         $rename = false;
         $sizeInfo = get_image_size_data($size);
         if ($img_size['width'] == $sizeInfo['width'] && $img_size['height'] <= $sizeInfo['height']) {
             $rename = true;
         } elseif ($img_size['height'] == $sizeInfo['height'] && $img_size['width'] <= $sizeInfo['width']) {
             $rename = true;
         }
         if ($rename == true) {
             // Rename image
             $new_name = $dir . $image_name . '-' . $size . $ext;
             // Rename the intermediate size
             $rename_success = rename($image, $new_name);
             if ($rename_success) {
                 return $new_name;
             }
         }
     }
     // do nothing if not renamed
     return $image;
 }
Exemplo n.º 3
0
function check_size_exist($size)
{
    $registeredSized = get_intermediate_image_sizes();
    if (!in_array($size, $registeredSized)) {
        throw new Exception("This image size is not registered in wordpress");
    }
}
Exemplo n.º 4
0
 public function get_html($media_id, $sizes = null, array $attrs = array(), $square = false, $def_wp_size = null, $use_fallback = false)
 {
     if (empty($def_wp_size)) {
         $def_wp_size = $square ? 'thumbnail' : 'medium';
     }
     $img_src = wp_get_attachment_image_url($media_id, $def_wp_size);
     if (empty($img_src)) {
         $result = $use_fallback ? call_user_func_array(array($this, 'get_html_fallback'), func_get_args()) : false;
         return $result;
     }
     $img_srcset = wp_get_attachment_image_srcset($media_id, $def_wp_size);
     $img_data = array();
     foreach (get_intermediate_image_sizes() as $size) {
         $img_data[$size] = wp_get_attachment_image_src($media_id, $size);
     }
     $img_data = $this->filter_square($img_data, $square);
     if (!empty($this->filter_srcset)) {
         foreach ($this->filter_srcset as $filter) {
             $img_srcset = call_user_func($filter, $img_data, $media_id, $size, $attrs, $square, $def_wp_size);
         }
     }
     $attrs = array_merge(array('src' => $img_src, 'srcset' => $img_srcset, 'sizes' => $this->get_sizes($sizes)), $attrs);
     if (empty($attrs['srcset'])) {
         unset($attrs['srcset']);
         unset($attrs['sizes']);
     }
     $result = \Cibulka::Base('HTML', 'img', $attrs, true);
     return $result;
 }
Exemplo n.º 5
0
function pte_site_options_validate($input)
{
    //$sizes = pte_get_alternate_sizes(false);
    if (!current_user_can('manage_options')) {
        add_settings_error('pte_options_site', 'pte_options_error', __("Only users with the 'manage_options' capability may make changes to these settings.", PTE_DOMAIN));
        return pte_get_site_options();
    }
    $sizes = get_intermediate_image_sizes();
    $pte_hidden_sizes = array();
    foreach ($sizes as $size) {
        // Hidden
        if (is_array($input['pte_hidden_sizes']) and in_array($size, $input['pte_hidden_sizes'])) {
            $pte_hidden_sizes[] = $size;
        }
    }
    $output = array('pte_hidden_sizes' => $pte_hidden_sizes);
    // Check the JPEG Compression value
    if ($input['pte_jpeg_compression'] != "") {
        $tmp_jpeg_compression = (int) preg_replace("/[\\D]/", "", $input['pte_jpeg_compression']);
        if (!is_int($tmp_jpeg_compression) || $tmp_jpeg_compression < 0 || $tmp_jpeg_compression > 100) {
            add_settings_error('pte_options_site', 'pte_options_error', __("JPEG Compression needs to be set from 0 to 100.", PTE_DOMAIN) . $tmp_jpeg_compression . "/" . $input['pte_jpeg_compression']);
        }
        $output['pte_jpeg_compression'] = $tmp_jpeg_compression;
    }
    // Cache Buster
    $output['cache_buster'] = isset($input['pte_cache_buster']);
    return $output;
}
 public function getImage($id)
 {
     $image_fields = array("ID" => "ID", "guid" => "file", "post_mime_type" => "mime_type");
     $indexable_image_size = get_intermediate_image_sizes();
     $uploadDir = wp_upload_dir();
     $uploadBaseUrl = $uploadDir['baseurl'];
     $image = new \stdClass();
     $post = get_post($id);
     foreach ($image_fields as $key => $value) {
         $image->{$value} = $post->{$key};
     }
     $metas = get_post_meta($post->ID, '_wp_attachment_metadata', true);
     $image->width = $metas["width"];
     $image->height = $metas["height"];
     $image->file = sprintf('%s/%s', $uploadBaseUrl, $metas["file"]);
     $image->sizes = $metas["sizes"] ? $metas["sizes"] : array();
     foreach ($image->sizes as $size => &$sizeAttrs) {
         if (in_array($size, $indexable_image_size) == false) {
             unset($image->sizes[$size]);
             continue;
         }
         $baseFileUrl = str_replace(wp_basename($metas['file']), '', $metas['file']);
         $sizeAttrs['file'] = sprintf('%s/%s%s', $uploadBaseUrl, $baseFileUrl, $sizeAttrs['file']);
     }
     return $image;
 }
function ilab_get_image_sizes($size = null)
{
    global $_wp_additional_image_sizes;
    $sizes = [];
    $get_intermediate_image_sizes = get_intermediate_image_sizes();
    // Create the full array with sizes and crop info
    foreach ($get_intermediate_image_sizes as $_size) {
        if (in_array($_size, ['thumbnail', 'medium', 'large'])) {
            $sizes[$_size]['width'] = get_option($_size . '_size_w');
            $sizes[$_size]['height'] = get_option($_size . '_size_h');
            $sizes[$_size]['crop'] = (bool) get_option($_size . '_crop');
        } else {
            if (isset($_wp_additional_image_sizes[$_size])) {
                $sizes[$_size] = ['width' => $_wp_additional_image_sizes[$_size]['width'], 'height' => $_wp_additional_image_sizes[$_size]['height'], 'crop' => $_wp_additional_image_sizes[$_size]['crop']];
            }
        }
    }
    if ($size != null) {
        if (isset($sizes[$size])) {
            return $sizes[$size];
        }
        return null;
    }
    return $sizes;
}
Exemplo n.º 8
0
 /**
  * Returns image sizes options.
  *
  * @since 1.2
  *
  * @param bool $add_disable Add disable option or not.
  * @param array $allowed Allowed array.
  * @param bool $show_dimension Show or hide dimension.
  */
 function simple_life_get_image_sizes_options($add_disable = true, $allowed = array(), $show_dimension = true)
 {
     global $_wp_additional_image_sizes;
     $get_intermediate_image_sizes = get_intermediate_image_sizes();
     $choices = array();
     if (true === $add_disable) {
         $choices['disable'] = esc_html__('No Image', 'simple-life');
     }
     $choices['thumbnail'] = esc_html__('Thumbnail', 'simple-life');
     $choices['medium'] = esc_html__('Medium', 'simple-life');
     $choices['large'] = esc_html__('Large', 'simple-life');
     $choices['full'] = esc_html__('Full (original)', 'simple-life');
     if (true === $show_dimension) {
         foreach (array('thumbnail', 'medium', 'large') as $key => $_size) {
             $choices[$_size] = $choices[$_size] . ' (' . get_option($_size . '_size_w') . 'x' . get_option($_size . '_size_h') . ')';
         }
     }
     if (!empty($_wp_additional_image_sizes) && is_array($_wp_additional_image_sizes)) {
         foreach ($_wp_additional_image_sizes as $key => $size) {
             $choices[$key] = $key;
             if (true === $show_dimension) {
                 $choices[$key] .= ' (' . $size['width'] . 'x' . $size['height'] . ')';
             }
         }
     }
     if (!empty($allowed)) {
         foreach ($choices as $key => $value) {
             if (!in_array($key, $allowed)) {
                 unset($choices[$key]);
             }
         }
     }
     return $choices;
 }
Exemplo n.º 9
0
 function get_value($id)
 {
     $paths = array();
     $meta = get_post_meta($id, '_wp_attachment_metadata', true);
     if (!isset($meta['sizes'])) {
         return $this->get_empty_char();
     }
     // available sizes
     if ($intersect = array_intersect(array_keys($meta['sizes']), get_intermediate_image_sizes())) {
         $url = wp_get_attachment_url($id);
         $filename = basename($url);
         $paths[] = "<a title='{$filename}' href='{$url}'>" . __('full size', 'codepress-admin-columns') . "</a>";
         foreach ($intersect as $size) {
             $src = wp_get_attachment_image_src($id, $size);
             if (!empty($src[0])) {
                 $filename = basename($src[0]);
                 $paths[] = "<a title='{$filename}' href='{$src[0]}' class='available'>{$size}</a>";
             }
         }
     }
     global $_wp_additional_image_sizes;
     if (!empty($_wp_additional_image_sizes)) {
         if (isset($_wp_additional_image_sizes['post-thumbnail'])) {
             unset($_wp_additional_image_sizes['post-thumbnail']);
         }
         // image does not have these additional sizes rendered yet
         if ($missing = array_diff(array_keys($_wp_additional_image_sizes), array_keys($meta['sizes']))) {
             foreach ($missing as $size) {
                 $paths[] = "<span title='Missing size: Try regenerate thumbnails with the plugin: Force Regenerate Thumbnails' href='javascript:;' class='not-available'>{$size}</span>";
             }
         }
     }
     return "<div class='sizes'>" . implode('<span class="cpac-divider"></span>', $paths) . "</div>";
 }
Exemplo n.º 10
0
/**
 * Loop through registered image sizes and add placeholders
 *
 * @global array $_wp_additional_image_sizes
 */
function add_placeholder_sizes()
{
    global $_wp_additional_image_sizes;
    if (!isset($_wp_additional_image_sizes)) {
        $_wp_additional_image_sizes = array();
    }
    $new_sizes = array();
    foreach (get_intermediate_image_sizes() as $name) {
        if (isset($_wp_additional_image_sizes[$name]['width'])) {
            $width = absint($_wp_additional_image_sizes[$name]['width']);
        } else {
            $width = absint(get_option("{$name}_size_w"));
        }
        if (isset($_wp_additional_image_sizes[$name]['height'])) {
            $height = absint($_wp_additional_image_sizes[$name]['height']);
        } else {
            $height = absint(get_option("{$name}_size_h"));
        }
        if (isset($_wp_additional_image_sizes[$name]['crop'])) {
            $crop = $_wp_additional_image_sizes[$name]['crop'];
        } else {
            $crop = get_option("{$name}_crop");
        }
        $new_sizes[$name . '-ph'] = array('width' => $width, 'height' => $height, 'crop' => $crop);
    }
    $_wp_additional_image_sizes = array_merge($_wp_additional_image_sizes, $new_sizes);
}
Exemplo n.º 11
0
 /**
  * @param array $settings [ image => [ id => '', url => '' ], image_size => '', hover_animation => '' ]
  *
  * @return string
  */
 public static function get_attachment_image_html($settings)
 {
     $id = $settings['image']['id'];
     $url = $settings['image']['url'];
     // Old version of image settings
     if (!isset($settings['image_size'])) {
         $settings['image_size'] = '';
     }
     $size = $settings['image_size'];
     $image_class = !empty($settings['hover_animation']) ? 'elementor-animation-' . $settings['hover_animation'] : '';
     $html = '';
     // If is the new version - with image size
     $image_sizes = get_intermediate_image_sizes();
     $image_sizes[] = 'full';
     if (!empty($id) && in_array($size, $image_sizes)) {
         $image_class .= " attachment-{$size} size-{$size}";
         $html .= wp_get_attachment_image($id, $size, false, ['class' => trim($image_class)]);
     } else {
         $image_src = Group_Control_Image_Size::get_attachment_image_src($id, 'image', $settings);
         if (!$image_src) {
             $image_src = $url;
         }
         $image_class_html = !empty($image_class) ? ' class="' . $image_class . '"' : '';
         $html .= sprintf('<img src="%s" title="%s" alt="%s"%s />', esc_attr($image_src), Control_Media::get_image_title($settings['image']), Control_Media::get_image_alt($settings['image']), $image_class_html);
     }
     return $html;
 }
Exemplo n.º 12
0
function sri_get_image_sizes($prefix = 'src-')
{
    global $_wp_additional_image_sizes;
    $other_sizes = array();
    foreach (get_intermediate_image_sizes() as $s) {
        if (isset($_wp_additional_image_sizes[$s]['width'])) {
            // For theme-added sizes
            $width = intval($_wp_additional_image_sizes[$s]['width']);
        } else {
            // For default sizes set in options
            $width = get_option("{$s}_size_w");
        }
        // Set height
        if (isset($_wp_additional_image_sizes[$s]['height'])) {
            // For theme-added sizes
            $height = intval($_wp_additional_image_sizes[$s]['height']);
        } else {
            // For default sizes set in options
            $height = get_option("{$s}_size_h");
        }
        $other_sizes[] = array($prefix . $s, $width, $height);
    }
    $other_sizes[] = array($prefix . "full", 'max', 'max');
    return $other_sizes;
}
Exemplo n.º 13
0
/**
 * Returns a set of image attachment links based on size.
 *
 * @since 1.0.0
 * @access public
 * @return string
 */
function hoot_get_image_size_links()
{
    /* If not viewing an image attachment page, return. */
    if (!wp_attachment_is_image(get_the_ID())) {
        return;
    }
    /* Set up an empty array for the links. */
    $links = array();
    /* Get the intermediate image sizes and add the full size to the array. */
    $sizes = get_intermediate_image_sizes();
    $sizes[] = 'full';
    /* Loop through each of the image sizes. */
    foreach ($sizes as $size) {
        /* Get the image source, width, height, and whether it's intermediate. */
        $image = wp_get_attachment_image_src(get_the_ID(), $size);
        /* Add the link to the array if there's an image and if $is_intermediate (4th array value) is true or full size. */
        if (!empty($image) && (true === $image[3] || 'full' == $size)) {
            /* Translators: Media dimensions - 1 is width and 2 is height. */
            $label = sprintf(__('%1$s &#215; %2$s', 'chromatic'), number_format_i18n(absint($image[1])), number_format_i18n(absint($image[2])));
            $links[] = sprintf('<a class="image-size-link">%s</a>', $label);
        }
    }
    /* Join the links in a string and return. */
    return join(' <span class="sep">/</span> ', $links);
}
Exemplo n.º 14
0
 /**
  * Get image sizes
  *
  * @return array
  */
 function kt_get_image_sizes($full = true, $custom = false)
 {
     global $_wp_additional_image_sizes;
     $get_intermediate_image_sizes = get_intermediate_image_sizes();
     $sizes = array();
     // Create the full array with sizes and crop info
     foreach ($get_intermediate_image_sizes as $_size) {
         if (in_array($_size, array('thumbnail', 'medium', 'large'))) {
             $sizes[$_size]['width'] = get_option($_size . '_size_w');
             $sizes[$_size]['height'] = get_option($_size . '_size_h');
             $sizes[$_size]['crop'] = (bool) get_option($_size . '_crop');
         } elseif (isset($_wp_additional_image_sizes[$_size])) {
             $sizes[$_size] = array('width' => $_wp_additional_image_sizes[$_size]['width'], 'height' => $_wp_additional_image_sizes[$_size]['height'], 'crop' => $_wp_additional_image_sizes[$_size]['crop']);
         }
         $option_text = array();
         $option_text[] = ucfirst(str_replace('_', ' ', $_size));
         if (isset($sizes[$_size])) {
             $option_text[] = '(' . $sizes[$_size]['width'] . ' x ' . $sizes[$_size]['height'] . ')';
             if ($sizes[$_size]['crop']) {
                 $option_text[] = esc_html__('Crop', 'adroit');
             }
             $sizes[$_size] = implode(' - ', $option_text);
         }
     }
     if ($full) {
         $sizes['full'] = esc_html__('Full', 'adroit');
     }
     if ($custom) {
         $sizes['custom'] = esc_html__('Custom size', 'adroit');
     }
     return $sizes;
 }
Exemplo n.º 15
0
 function gdlr_get_video_size($size)
 {
     global $_wp_additional_image_sizes, $theme_option, $gdlr_crop_video;
     // get video ratio
     if (!empty($theme_option['video-ratio']) && preg_match('#^(\\d+)[\\/:](\\d+)$#', $theme_option['video-ratio'], $number)) {
         $ratio = $number[1] / $number[2];
     } else {
         $ratio = 16 / 9;
     }
     // get video size
     $video_size = array('width' => 620, 'height' => 9999);
     if (!empty($size) && is_numeric($size)) {
         $video_size['width'] = intval($size);
     } else {
         if (!empty($size) && !empty($_wp_additional_image_sizes[$size])) {
             $video_size = $_wp_additional_image_sizes[$size];
         } else {
             if (!empty($size) && in_array($size, get_intermediate_image_sizes())) {
                 $video_size = array('width' => get_option($size . '_size_w'), 'height' => get_option($size . '_size_h'));
             }
         }
     }
     // refine video size
     if ($gdlr_crop_video || $video_size['height'] == 9999) {
         return array('width' => $video_size['width'], 'height' => intval($video_size['width'] / $ratio));
     } else {
         if ($video_size['width'] == 9999) {
             return array('width' => intval($video_size['height'] * $ratio), 'height' => $video_size['height']);
         }
     }
     return $video_size;
 }
Exemplo n.º 16
0
 /**
  * Init
  */
 public function __construct()
 {
     /** Ajax pagination for property_overview */
     add_action("wp_ajax_wpp_property_overview_pagination", array($this, "ajax_handler"));
     add_action("wp_ajax_nopriv_wpp_property_overview_pagination", array($this, "ajax_handler"));
     $custom_attributes = ud_get_wp_property('property_stats', array());
     $image_sizes = array('' => __('No Image', ud_get_wp_property('domain')));
     foreach (get_intermediate_image_sizes() as $name) {
         $sizes = \WPP_F::image_sizes($name);
         if (!$sizes) {
             continue;
         }
         $image_sizes[$name] = $name . ' (' . $sizes['width'] . 'x' . $sizes['height'] . 'px)';
     }
     $sort_by = array('post_date' => sprintf(__('Post Date (%s)', ud_get_wp_property('domain')), 'post_date'), 'post_modified' => sprintf(__('Modified Date (%s)', ud_get_wp_property('domain')), 'post_modified'), 'random' => sprintf(__('Random (%s)', ud_get_wp_property('domain')), 'random'), 'menu_order' => sprintf(__('Menu Order (%s)', ud_get_wp_property('domain')), 'menu_order'));
     $sortable_atts = ud_get_wp_property('sortable_attributes', array());
     if (!empty($sortable_atts) && is_array($sortable_atts)) {
         foreach ($sortable_atts as $attr) {
             if (array_key_exists($attr, $custom_attributes)) {
                 $sort_by[$attr] = $custom_attributes[$attr] . ' (' . $attr . ')';
             }
         }
     }
     $options = array('id' => 'property_overview', 'params' => array('property_id' => array('name' => __('Property ID', ud_get_wp_property()->domain), 'description' => __('If not empty, result will show particular property, which ID is set.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'post_parent' => array('name' => sprintf(__('Parent %s', ud_get_wp_property('domain')), \WPP_F::property_label()), 'description' => sprintf(__('If not empty, result will show children of particular property, which ID is set. You can use dynamic attributes instead of ID such as %1$s or %2$s.<br/>%1$s - to list all the listings that are a child of the current %3$s.<br/>%2$s - to list all listings that are children of the same parent (i.e. siblings) of the current %3$s', ud_get_wp_property('domain')), '<b>post_id</b>', '<b>post_parent</b>', \WPP_F::property_label()), 'type' => 'text', 'default' => ''), 'property_type' => array('name' => sprintf(__('%s Type', ud_get_wp_property('domain')), \WPP_F::property_label()), 'description' => sprintf(__('The list of %s types to be included. If no type checked, all available %s will be shown.', ud_get_wp_property('domain')), \WPP_F::property_label(), \WPP_F::property_label('plural')), 'type' => 'multi_checkbox', 'options' => ud_get_wp_property('property_types')), 'featured' => array('name' => sprintf(__('Show only Featured %s', ud_get_wp_property('domain')), \WPP_F::property_label('plural')), 'type' => 'checkbox'), 'custom_query' => array('name' => __('Custom Query by Attributes Values', ud_get_wp_property()->domain), 'description' => sprintf(__('Setup your custom query by providing values for specific attributes. Empty values will be ignored. Example:<br/>- to list only %1$s which have minimum 2 and maximum 4 bedrooms, you should set <b>2-4</b> value for your Bedrooms attribute.<br/>- to list only %1$s which have 1 or 3 bathrooms, you should set <b>1,3</b> value for your Batrooms attribute.', ud_get_wp_property('domain')), \WPP_F::property_label()), 'type' => 'custom_attributes', 'options' => $custom_attributes), 'show_children' => array('name' => __('Show Children', ud_get_wp_property()->domain), 'description' => sprintf(__('Switches children %s displaying.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'true'), 'child_properties_title' => array('name' => sprintf(__('Child %s Title', ud_get_wp_property()->domain), \WPP_F::property_label('plural')), 'description' => sprintf(__('Title for Child %s section.', ud_get_wp_property()->domain), \WPP_F::property_label('plural')), 'type' => 'text', 'default' => __('Floor plans at location:', ud_get_wp_property()->domain)), 'fancybox_preview' => array('name' => __('Fancybox Preview', ud_get_wp_property()->domain), 'description' => __('Use fancybox preview.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'true'), 'bottom_pagination_flag' => array('name' => __('Bottom Pagination', ud_get_wp_property()->domain), 'description' => __('Show Bottom Pagination.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'thumbnail_size' => array('name' => __('Thumbnail Size', ud_get_wp_property()->domain), 'description' => __('Show image with specific image size', ud_get_wp_property()->domain), 'type' => 'select', 'options' => $image_sizes, 'default' => 'thumbnail'), 'sort_by_text' => array('name' => __('Sort By Text', ud_get_wp_property()->domain), 'description' => __('Renames "Sort By:" text.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => __('Sort By', ud_get_wp_property()->domain)), 'sort_by' => array('name' => __('Sort By', ud_get_wp_property()->domain), 'description' => sprintf(__('Sets sorting by sortable attribute or %s.', ud_get_wp_property()->domain), 'post_date, menu_order, random'), 'type' => 'select', 'options' => $sort_by, 'default' => 'post_date'), 'sort_order' => array('name' => __('Sort Order', ud_get_wp_property()->domain), 'description' => __('Sort Order', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('DESC' => 'DESC', 'ASC' => 'ASC'), 'default' => 'DESC'), 'template' => array('name' => __('Template', ud_get_wp_property()->domain), 'description' => sprintf(__('Sets layout using PHP template name. Your custom template should be stored in your theme\'s root directory. Example:<br/>if your custom template is called %s, the value of template must be %s.', ud_get_wp_property('domain')), '<b>property-overview-grid.php</b>', '<b>grid</b>'), 'type' => 'text'), 'sorter_type' => array('name' => __('Sorter Type', ud_get_wp_property()->domain), 'description' => __('Sorter Type', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('none' => __('None', ud_get_wp_property()->domain), 'buttons' => __('Buttons', ud_get_wp_property()->domain), 'dropdown' => __('Dropdown', ud_get_wp_property()->domain)), 'default' => 'buttons'), 'sorter' => array('name' => __('Sorter', ud_get_wp_property()->domain), 'description' => __('Show Sort UI', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('On', ud_get_wp_property()->domain), 'off' => __('Off', ud_get_wp_property()->domain)), 'default' => 'on'), 'pagination' => array('name' => __('Pagination', ud_get_wp_property()->domain), 'description' => __('Show Pagination', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('On', ud_get_wp_property()->domain), 'off' => __('Off', ud_get_wp_property()->domain)), 'default' => 'on'), 'pagination_type' => array('name' => __('Pagination Type', ud_get_wp_property()->domain), 'description' => __('Determine pagination UI', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('slider' => __('slider', ud_get_wp_property()->domain), 'numeric' => __('numeric', ud_get_wp_property()->domain)), 'default' => ud_get_wp_property('configuration.property_overview.pagination_type') ? ud_get_wp_property('configuration.property_overview.pagination_type') : 'slider'), 'per_page' => array('name' => __('Per Page', ud_get_wp_property()->domain), 'description' => sprintf(__('%s quantity per page.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'number', 'default' => 10), 'starting_row' => array('name' => __('Starting Row', ud_get_wp_property()->domain), 'description' => __('Sets starting row.', ud_get_wp_property()->domain), 'type' => 'number', 'default' => 0), 'detail_button' => array('name' => __('Detail Button', ud_get_wp_property()->domain), 'description' => __('Name of Detail Button. Button will not be shown if the value is empty.', ud_get_wp_property()->domain), 'type' => 'text'), 'hide_count' => array('name' => __('Hide Count', ud_get_wp_property()->domain), 'description' => __('Hide the "10 found." text.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'in_new_window' => array('name' => __('In new window?', ud_get_wp_property()->domain), 'description' => __('Open links in new window.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'strict_search' => array('name' => __('Strict Search', ud_get_wp_property()->domain), 'description' => __('Provides strict search', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false')), 'description' => sprintf(__('Renders %s Attributes', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property');
     parent::__construct($options);
 }
Exemplo n.º 17
0
/**
 * Get size information for all currently-registered image sizes.
 *
 * @global $_wp_additional_image_sizes
 * @uses   get_intermediate_image_sizes()
 * @return array $sizes Data for all currently-registered image sizes.
 */
function get_image_sizes()
{
    global $_wp_additional_image_sizes;
    $sizes = array();
    $output = '';
    foreach (get_intermediate_image_sizes() as $_size) {
        if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
            $sizes[$_size]['width'] = get_option("{$_size}_size_w");
            $sizes[$_size]['height'] = get_option("{$_size}_size_h");
            $sizes[$_size]['crop'] = (bool) get_option("{$_size}_crop");
        } elseif (isset($_wp_additional_image_sizes[$_size])) {
            $sizes[$_size] = array('width' => $_wp_additional_image_sizes[$_size]['width'], 'height' => $_wp_additional_image_sizes[$_size]['height'], 'crop' => $_wp_additional_image_sizes[$_size]['crop']);
        }
    }
    foreach ($sizes as $image_size => $image_size_data) {
        $crop = '';
        if (is_array($image_size_data['crop'])) {
            $crop = 'true ' . $image_size_data['crop'][0] . '-' . $image_size_data['crop'][0];
        } else {
            $crop = $image_size_data['crop'] ? 'true auto' : 'false';
        }
        $output .= '<tr><td>' . $image_size . '</td><td> ' . $image_size_data['width'] . 'x' . $image_size_data['height'] . '</td><td>Croop: ' . $crop . '</td></tr> ';
    }
    return '<table>' . $output . '</table>';
}
Exemplo n.º 18
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        extract($args);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        global $post;
        //Returns Array of Term Names for "collection"
        $terms = wp_get_post_terms($post->ID, 'collection', array("fields" => "slugs"));
        if (!empty($terms)) {
            $args = array('tax_query' => array(array('taxonomy' => 'collection', 'field' => 'slug', 'terms' => $terms)), 'posts_per_page' => '6', 'orderby' => 'rand');
        } else {
            $args = array('post_type' => 'sell_media_item', 'field' => 'slug', 'orderby' => 'rand', 'posts_per_page' => '6');
        }
        ?>

        <div class="sell-media-similar-widget sell-media">

            <?php 
        // Get available image sizes
        $image_sizes = get_intermediate_image_sizes();
        ?>

            <?php 
        $type_posts = new WP_Query($args);
        ?>
            <?php 
        while ($type_posts->have_posts()) {
            $type_posts->the_post();
            global $post;
            ?>

            <div class="sell-media-widget-item-warp sell-media-grid">
                <div class="sell-media-widget-thumb-wrap">
                    <a href="<?php 
            echo get_permalink();
            ?>
">
                        <?php 
            sell_media_item_icon($post->ID, apply_filters('sell_media_thumbnail', 'thumbnail'));
            ?>
                    </a>
                </div>
            </div> <!--  .sell-media-widget-item-warp  -->

    <?php 
        }
        wp_reset_postdata();
        ?>

</div><!-- .sell-media-recent -->


<?php 
        echo $after_widget;
    }
Exemplo n.º 19
0
 function slupy_shortcode_options_for_ts($args)
 {
     foreach (get_intermediate_image_sizes() as $key => $image_size) {
         $all_image_size[] = array('label' => $image_size, 'value' => $image_size);
     }
     $slupy_settings = array(array('title' => __('Portfolio', TS_PTD), 'id' => 'slupy_portfolio', 'shortcode' => '[slupy_portfolio{attr}]', 'options' => array(array('title' => __('Thumbnail Model', TS_PTD), 'name' => 'model', 'id' => '', 'dependid' => 'portfolio_model', 'class' => '', 'choices' => array(array('label' => __('Model 1', TS_PTD), 'value' => '1'), array('label' => __('Model 2', TS_PTD), 'value' => '2'), array('label' => __('Model 3', TS_PTD), 'value' => '3')), 'value' => '', 'type' => 'select'), array('title' => __('List Type', TS_PTD), 'name' => 'masonry', 'id' => '', 'dependid' => 'portfolio_masonry', 'depends' => 'portfolio_model:1|2', 'class' => 'big_switch', 'value' => 'on', 'text' => __('MASONRY', TS_PTD) . ':' . __('GRID', TS_PTD), 'type' => 'switch'), array('title' => __('Fit Grid Height?', TS_PTD), 'name' => 'fit_grid', 'id' => '', 'depends' => 'portfolio_model:1|2 + portfolio_masonry:off', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Loop Items Padding?', TS_PTD), 'name' => 'padding', 'id' => '', 'depends' => 'portfolio_model:1|2', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Filterable', TS_PTD), 'name' => 'filterable', 'id' => '', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Portfolio Max Columns', TS_PTD), 'name' => 'max_columns', 'id' => '', 'class' => '', 'choices' => array(array('label' => '2', 'value' => '2'), array('label' => '3', 'value' => '3'), array('label' => '4', 'value' => '4'), array('label' => '5', 'value' => '5')), 'value' => '3', 'type' => 'select'), array('title' => __('Pagination Style', TS_PTD), 'name' => 'pagination', 'id' => '', 'class' => '', 'choices' => array(array('label' => __('Load More', TS_PTD), 'value' => 'loadmore'), array('label' => __('Older & Newer Button', TS_PTD), 'value' => 'oldernewer'), array('label' => __('Page Numbers', TS_PTD), 'value' => 'pagenumbers')), 'value' => '', 'type' => 'select'), array('title' => __('Portfolio Per Page', TS_PTD), 'name' => 'posts_per_page', 'id' => '', 'class' => '', 'value' => '10', 'min_max_step' => '2,30,1', 'type' => 'numeric-slider'), array('title' => __('Image Size', TS_PTD), 'name' => 'image_size', 'id' => '', 'class' => '', 'choices' => $all_image_size, 'value' => '', 'type' => 'select'))), array('title' => __('Latest Projects', TS_PTD), 'id' => 'slupy_cportfolio', 'shortcode' => '[slupy_cportfolio{attr}]', 'options' => array(array('title' => __('Thumbnail Model', TS_PTD), 'name' => 'model', 'id' => '', 'class' => '', 'choices' => array(array('label' => __('Model 1', TS_PTD), 'value' => '1'), array('label' => __('Model 2', TS_PTD), 'value' => '2')), 'value' => '', 'type' => 'select'), array('title' => __('Limit', TS_PTD), 'name' => 'limit', 'id' => '', 'class' => '', 'value' => '8', 'min_max_step' => '4,12,1', 'type' => 'numeric-slider'), array('title' => __('Image Size', TS_PTD), 'name' => 'image_size', 'id' => '', 'class' => '', 'choices' => $all_image_size, 'value' => '', 'type' => 'select'), array('title' => __('Auto Play', TS_PTD), 'name' => 'autoplay', 'id' => '', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Stop on Hover', TS_PTD), 'name' => 'stop_hover', 'id' => '', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Pagination', TS_PTD), 'name' => 'pagination', 'id' => '', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Touch Drag', TS_PTD), 'name' => 'touch_drag', 'id' => '', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Slide Duration Time (second)', TS_PTD), 'name' => 'duration_time', 'id' => '', 'class' => '', 'value' => '4', 'min_max_step' => '2,30,1', 'type' => 'numeric-slider', 'depends' => 'ourclients_sc_autoplay:on'), array('title' => __('Show Max Items (Wide)', TS_PTD), 'name' => 'show_max_item', 'id' => '', 'class' => '', 'value' => '4', 'min_max_step' => '2,10,1', 'type' => 'numeric-slider'), array('title' => __('Show Max Items (Desktop)', TS_PTD), 'name' => 'show_max_desktop', 'id' => '', 'class' => '', 'value' => '3', 'min_max_step' => '2,10,1', 'type' => 'numeric-slider'), array('title' => __('Show Max Items (Tablet)', TS_PTD), 'name' => 'show_max_tablet', 'id' => '', 'class' => '', 'value' => '2', 'min_max_step' => '1,10,1', 'type' => 'numeric-slider'), array('title' => __('Show Max Items (Mobile)', TS_PTD), 'name' => 'show_max_mobile', 'id' => '', 'class' => '', 'value' => '1', 'min_max_step' => '1,10,1', 'type' => 'numeric-slider'))), array('title' => __('Blog', TS_PTD), 'id' => 'slupy_blog', 'shortcode' => '[slupy_blog{attr}]', 'options' => array(array('title' => __('Masonry Style', TS_PTD), 'name' => 'masonry', 'id' => '', 'dependid' => 'masonry_style', 'class' => '', 'value' => 'on', 'text' => __('ON', TS_PTD) . ':' . __('OFF', TS_PTD), 'type' => 'switch'), array('title' => __('Masonry Max Columns', TS_PTD), 'name' => 'masonry_columns', 'id' => '', 'depends' => 'masonry_style:on', 'class' => '', 'choices' => array(array('label' => '2', 'value' => '2'), array('label' => '3', 'value' => '3'), array('label' => '4', 'value' => '4')), 'value' => '', 'type' => 'select'), array('title' => __('Masonry Effect', TS_PTD), 'name' => 'effect', 'id' => '', 'depends' => 'masonry_style:on', 'class' => '', 'choices' => array(array('label' => __('fade', TS_PTD), 'value' => 'fadeIn'), array('label' => __('fadeInDown', TS_PTD), 'value' => 'fadeInDown'), array('label' => __('fadeInUp', TS_PTD), 'value' => 'fadeInUp'), array('label' => __('bounceIn', TS_PTD), 'value' => 'bounceIn'), array('label' => __('flipInX', TS_PTD), 'value' => 'flipInX'), array('label' => __('flipInY', TS_PTD), 'value' => 'flipInY')), 'value' => '', 'type' => 'select'), array('title' => __('Posts Per Page', TS_PTD), 'name' => 'posts_per_page', 'id' => '', 'class' => '', 'value' => '10', 'min_max_step' => '2,30,1', 'type' => 'numeric-slider'), array('title' => __('Pagination Style', TS_PTD), 'name' => 'pagination', 'id' => '', 'class' => '', 'choices' => array(array('label' => __('Load More', TS_PTD), 'value' => 'loadmore'), array('label' => __('Older & Newer Button', TS_PTD), 'value' => 'oldernewer'), array('label' => __('Page Numbers', TS_PTD), 'value' => 'pagenumbers')), 'value' => '', 'type' => 'select'), array('title' => __('Meta Position', TS_PTD), 'name' => 'meta_position', 'id' => '', 'class' => '', 'choices' => array(array('label' => __('Content After', TS_PTD), 'value' => 'content-after'), array('label' => __('Media After', TS_PTD), 'value' => 'media-after'), array('label' => __('Heading After', TS_PTD), 'value' => 'heading-after'), array('label' => __('Together with Read More Button', TS_PTD), 'value' => 'read-more')), 'value' => '', 'type' => 'select'))));
     return array_merge($args, $slupy_settings);
 }
Exemplo n.º 20
0
 public function appendImageSizes($field)
 {
     $sizes = get_intermediate_image_sizes();
     foreach ($sizes as $size) {
         $field['choices'][$size] = $size;
     }
     return $field;
 }
Exemplo n.º 21
0
 public function registerVcWidget()
 {
     $native_dependency = array("element" => "theme", "value" => array('native'));
     $galleria_dependency = array("element" => "theme", "value" => array_diff(array_keys(self::getThemes()), array('native')));
     /* Gallery/Slideshow
     		---------------------------------------------------------- */
     vc_map(array('name' => __('Image Gallery', $this->textDomain), 'base' => 'gallery', "class" => "", "icon" => "xt_vc_icon_gallery", "category" => _x('XplodedThemes Widgets', 'VC', $this->textDomain), 'description' => __('Responsive image gallery slider', $this->textDomain), 'params' => array(array('type' => 'textfield', 'heading' => __('Widget title', $this->textDomain), 'holder' => "div", 'class' => 'xt_vc_title', 'param_name' => 'title', 'description' => __('Enter text which will be used as widget title. Leave blank if no title is needed.', $this->textDomain)), array("type" => "dropdown", "holder" => "div", "heading" => _x("Theme", 'VC', $this->textDomain), "param_name" => "theme", "value" => array_flip(self::getThemes()), "description" => ''), array('type' => 'attach_images', 'heading' => __('Images', $this->textDomain), 'holder' => "div", 'class' => 'xt_vc_images', 'param_name' => 'ids', 'value' => '', 'description' => __('Select images from media library.', $this->textDomain)), array("type" => "dropdown", "holder" => "div", "heading" => _x("Columns", 'VC', $this->textDomain), "param_name" => "columns", "value" => array(1, 2, 3, 4, 5, 6, 7, 8, 9), "description" => '', "dependency" => $native_dependency), array("type" => "dropdown", "holder" => "div", "heading" => _x("Thumb Size", 'VC', $this->textDomain), "param_name" => "size", "value" => get_intermediate_image_sizes(), "description" => '', "dependency" => $native_dependency), array('type' => 'textfield', 'heading' => __('Max Height', $this->textDomain), 'holder' => "div", 'param_name' => 'height', 'description' => __('Max Image Height in Pixels. Leave empty for automatic height detection', $this->textDomain)), array("type" => "dropdown", "holder" => "div", "heading" => _x("Link", 'VC', $this->textDomain), "param_name" => "link", "value" => array(__('No Link', $this->textDomain) => 'none', __('Link to attachment page', $this->textDomain) => 'file', __('Link to custom url', $this->textDomain) => 'link', __('Open in lightbox', $this->textDomain) => 'lightbox'), "description" => '', "dependency" => $native_dependency), array("type" => "dropdown", "holder" => "div", "heading" => _x("Transition", 'VC', $this->textDomain), "param_name" => "transition", "value" => array(__('Fade', $this->textDomain) => 'fade', __('Flash', $this->textDomain) => 'flash', __('Pulse', $this->textDomain) => 'pulse', __('Slide', $this->textDomain) => 'slide', __('Fade / Slide', $this->textDomain) => 'fadeslide'), "description" => '', "dependency" => $galleria_dependency), array('type' => 'textfield', 'heading' => __('Transition Speed', $this->textDomain), 'holder' => "div", 'param_name' => 'transition_speed', 'description' => __('The milliseconds used in the animation when applying the transition. The higher number, the slower transition.', $this->textDomain), "value" => 400, "dependency" => $galleria_dependency), array('type' => 'checkbox', 'heading' => __('AutoPlay?', $this->textDomain), 'holder' => "div", 'param_name' => 'autoplay', 'value' => array(__('Yes', $this->textDomain) => 'AutoPlay'), "dependency" => $galleria_dependency), array('type' => 'textfield', 'heading' => __('Extra class name', $this->textDomain), 'param_name' => 'el_class', 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', $this->textDomain)))));
 }
 /**
  * Initialize product actions.
  */
 public function __construct()
 {
     add_filter("woocommerce_rest_{$this->post_type}_query", array($this, 'query_args'), 10, 2);
     add_action("woocommerce_rest_insert_{$this->post_type}", array($this, 'clear_transients'));
     /* Get the intermediate image sizes and add the full size to the array. */
     $this->image_sizes = get_intermediate_image_sizes();
     $this->image_sizes[] = 'full';
 }
Exemplo n.º 23
0
/**
 * Provides a Render selectbox with options for all registered image sizes.
 *
 * @since 1.0.0
 *
 * @return array All WP image sizes.
 */
function render_image_sizes_dropdown()
{
    $output = array('full' => 'Full');
    foreach (get_intermediate_image_sizes() as $size) {
        $output[$size] = render_translate_id_to_name($size);
    }
    return $output;
}
Exemplo n.º 24
0
 /**
  * Set the size data of the media to insert.
  * If no size is defined, default to 'full'.
  *
  * @return void
  */
 protected function setSize()
 {
     $sizes = get_intermediate_image_sizes();
     if (isset($this['size']) && !in_array($this['size'], $sizes)) {
         $this['size'] = 'full';
     } elseif (!isset($this['size'])) {
         $this['size'] = 'full';
     }
 }
Exemplo n.º 25
0
/**
 * Returns array of image sizes
 *
 * @since 1.0.0
 */
function wps_image_sizes()
{
    $sizes = array();
    $get_sizes = get_intermediate_image_sizes();
    array_unshift($get_sizes, 'full');
    $get_sizes = array_combine($get_sizes, $get_sizes);
    $sizes = array_merge($sizes, $get_sizes);
    return $sizes;
}
function pq_tunnel_pod_field($fields, $prefix = null)
{
    $out = array();
    // return out if fields are empty
    if (empty($fields)) {
        return $out;
    }
    foreach ($fields as $name => $field) {
        $out[] = $prefix . $name;
        if ($field['type'] === 'file' && $field['options']['file_uploader'] == 'attachment') {
            $out[] = $prefix . $name . '._src';
            $out[] = $prefix . $name . '._img';
            $sizes = get_intermediate_image_sizes();
            foreach ($sizes as &$size) {
                $out[] = $prefix . $name . '._src.' . $size;
            }
            if ('multi' != $field['options']['file_format_type']) {
                foreach ($sizes as &$size) {
                    $out[] = $prefix . $name . '._src_relative.' . $size;
                }
                foreach ($sizes as &$size) {
                    $out[] = $prefix . $name . '._src_schemeless.' . $size;
                }
            }
            foreach ($sizes as &$size) {
                $out[] = $prefix . $name . '._img.' . $size;
            }
        }
        if (!empty($field['table_info'])) {
            if (!empty($field['table_info']['pod'])) {
                if (false === strpos($prefix, $name . '.')) {
                    $pod = pods($field['table_info']['pod']['name']);
                    // only tunnel in if there are object fields
                    if (!empty($field['table_info']['object_fields'])) {
                        $out = array_merge($out, pq_tunnel_pod_field($field['table_info']['object_fields'], $prefix . $name . '.'));
                    }
                    if (post_type_supports($field['table_info']['pod']['name'], 'thumbnail')) {
                        $out[] = 'post_thumbnail';
                        $out[] = 'post_thumbnail_url';
                        $sizes = get_intermediate_image_sizes();
                        foreach ($sizes as &$size) {
                            $out[] = 'post_thumbnail.' . $size;
                            $out[] = 'post_thumbnail_url.' . $size;
                        }
                    }
                    $pod_fields = $pod->fields();
                    $out = array_merge($out, pq_tunnel_pod_field($pod_fields, $prefix . $name . '.'));
                }
            } else {
                if (!empty($field['table_info']['object_fields'])) {
                    $out = array_merge($out, pq_tunnel_pod_field($field['table_info']['object_fields'], $prefix . $name . '.'));
                }
            }
        }
    }
    return $out;
}
 /**
  * Get post image.
  *
  * @return string
  */
 public function get_image($args = array(), $type = 'post', $id = 0)
 {
     if (is_callable(array($this, 'get_' . $type . '_object'))) {
         $object = call_user_func(array($this, 'get_' . $type . '_object'), $id);
         if ('post' === $type && empty($object->ID) || 'term' === $type && empty($object->term_id)) {
             return '';
         }
     }
     $default_args = array('visible' => true, 'size' => apply_filters('cherry_normal_image_size', 'post-thumbnail'), 'mobile_size' => apply_filters('cherry_mobile_image_size', 'post-thumbnail'), 'html' => '<a href="%1$s" %2$s ><img src="%3$s" alt="%4$s" %5$s ></a>', 'class' => 'wp-image', 'placeholder' => true, 'placeholder_background' => '000', 'placeholder_foreground' => 'fff', 'placeholder_title' => '', 'html_tag_suze' => true, 'echo' => false);
     $args = wp_parse_args($args, $default_args);
     $html = '';
     if (filter_var($args['visible'], FILTER_VALIDATE_BOOLEAN)) {
         $size = wp_is_mobile() ? $args['mobile_size'] : $args['size'];
         $size = in_array($size, get_intermediate_image_sizes()) ? $size : 'post-thumbnail';
         // Place holder defaults attr
         $size_array = $this->get_thumbnail_size_array($size);
         switch ($type) {
             case 'post':
                 $id = $object->ID;
                 $thumbnail_id = get_post_thumbnail_id($id);
                 $alt = esc_attr($object->post_title);
                 $link = $this->get_post_permalink();
                 break;
             case 'term':
                 $id = $object->term_id;
                 $thumbnail_id = get_term_meta($id, $this->args['meta_key']['term_thumb'], true);
                 $alt = esc_attr($object->name);
                 $link = $this->get_term_permalink($id);
                 break;
             case 'attachment':
                 $thumbnail_id = $id;
                 $alt = get_the_title($thumbnail_id);
                 $link = wp_get_attachment_image_url($thumbnail_id, $size);
                 break;
         }
         if ($thumbnail_id) {
             $image_data = wp_get_attachment_image_src($thumbnail_id, $size);
             $src = $image_data[0];
             $size_array['width'] = $image_data[1];
             $size_array['height'] = $image_data[2];
         } elseif (filter_var($args['placeholder'], FILTER_VALIDATE_BOOLEAN)) {
             $title = $args['placeholder_title'] ? $args['placeholder_title'] : $size_array['width'] . 'x' . $size_array['height'];
             $attr = array('width' => $size_array['width'], 'height' => $size_array['height'], 'background' => $args['placeholder_background'], 'foreground' => $args['placeholder_foreground'], 'title' => $title);
             $attr = array_map('esc_attr', $attr);
             $width = 4000 < intval($attr['width']) ? 4000 : intval($attr['width']);
             $height = 4000 < intval($attr['height']) ? 4000 : intval($attr['height']);
             $src = $this->get_placeholder_url(array('width' => $width, 'height' => $height, 'background' => $attr['background'], 'foreground' => $attr['foreground'], 'title' => $attr['title']));
         }
         $class = $args['class'] ? 'class="' . $args['class'] . '"' : '';
         $html_tag_suze = filter_var($args['html_tag_suze'], FILTER_VALIDATE_BOOLEAN) ? 'width="' . $size_array['width'] . '" height="' . $size_array['height'] . '"' : '';
         if (isset($src)) {
             $html = sprintf($args['html'], $link, $class, $src, $alt, $html_tag_suze);
         }
     }
     return $this->output_method($html, $args['echo']);
 }
Exemplo n.º 28
0
 function initialize_form()
 {
     $intermediate = get_intermediate_image_sizes();
     $sizes = array();
     foreach ($intermediate as $name) {
         $sizes[$name] = ucwords(preg_replace('/[-_]/', ' ', $name));
     }
     $sizes = array_merge(array('full' => __('Full', 'so-widgets-bundle')), $sizes);
     return array('images' => array('type' => 'repeater', 'label' => __('Images', 'so-widgets-bundle'), 'item_name' => __('Image', 'so-widgets-bundle'), 'item_label' => array('selector' => "[name*='title']", 'update_event' => 'change', 'value_method' => 'val'), 'fields' => array('image' => array('type' => 'media', 'label' => __('Image', 'so-widgets-bundle')), 'title' => array('type' => 'text', 'label' => __('Image title', 'so-widgets-bundle')), 'url' => array('type' => 'link', 'label' => __('URL', 'so-widgets-bundle')))), 'display' => array('type' => 'section', 'label' => __('Display', 'so-widgets-bundle'), 'fields' => array('attachment_size' => array('label' => __('Image size', 'so-widgets-bundle'), 'type' => 'select', 'options' => $sizes, 'default' => 'full'), 'max_height' => array('label' => __('Maximum image height', 'so-widgets-bundle'), 'type' => 'number'), 'max_width' => array('label' => __('Maximum image width', 'so-widgets-bundle'), 'type' => 'number'), 'spacing' => array('label' => __('Spacing', 'so-widgets-bundle'), 'description' => __('Amount of spacing between images.', 'so-widgets-bundle'), 'type' => 'number', 'default' => 10))));
 }
 public static function get_all()
 {
     global $_wp_additional_image_sizes;
     $sizes_to_return = array();
     $image_sizes = get_intermediate_image_sizes();
     foreach ($image_sizes as $size_name) {
         $sizes_to_return[$size_name] = self::get_size_attributes($size_name);
     }
     return $sizes_to_return;
 }
Exemplo n.º 30
0
 /**
  * Modify the form widget
  *
  * @param $form
  *
  * @return mixed
  */
 function modify_form($form)
 {
     $intermediate = get_intermediate_image_sizes();
     foreach ($intermediate as $id => $name) {
         $intermediate[$id] = ucwords(str_replace('-', ' ', $name));
     }
     $sizes = array_merge(array('full' => __('Full', 'so-widgets-bundle')), $intermediate);
     $form['display']['fields']['attachment_size']['options'] = $sizes;
     return $form;
 }