当前位置: 首页>>代码示例>>PHP>>正文


PHP RevSliderFunctionsWP::get_image_id_by_url方法代码示例

本文整理汇总了PHP中RevSliderFunctionsWP::get_image_id_by_url方法的典型用法代码示例。如果您正苦于以下问题:PHP RevSliderFunctionsWP::get_image_id_by_url方法的具体用法?PHP RevSliderFunctionsWP::get_image_id_by_url怎么用?PHP RevSliderFunctionsWP::get_image_id_by_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RevSliderFunctionsWP的用法示例。


在下文中一共展示了RevSliderFunctionsWP::get_image_id_by_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_slider_speed

    /**
     * view the estimated speed of the Slider
     * @since: 5.0
     */
    public static function get_slider_speed($sliderID)
    {
        //$data = wp_get_attachment_metadata($cur_img_id);
        ob_start();
        $total_size = 0;
        $do_ssl = is_ssl() ? 'http:' : 'https:';
        $slider = new RevSliderSlider();
        $slider->initByID($sliderID);
        $slides = $slider->getSlidesForExport();
        $static_slides = $slider->getStaticSlideForExport();
        if (!empty($static_slides) && is_array($static_slides)) {
            foreach ($static_slides as $s_slide) {
                $slides[] = $s_slide;
            }
        }
        $used_images = array();
        $used_videos = array();
        $used_captions = array();
        $using_kenburns = false;
        $using_parallax = false;
        $using_carousel = false;
        $using_navigation = false;
        $using_videos = false;
        $using_actions = false;
        $using_layeranim = false;
        $img_size = 0;
        $video_size = 0;
        $slide_counter = 0;
        $firstslide_size = 0;
        $smartslide_size = 0;
        if ($slider->getParam("use_parallax", "off") == 'on') {
            $using_parallax = true;
        }
        if ($slider->getParam("slider-type", "standard") == 'carousel') {
            $using_carousel = true;
        }
        $enable_arrows = $slider->getParam('enable_arrows', 'off');
        $enable_bullets = $slider->getParam('enable_bullets', 'off');
        $enable_tabs = $slider->getParam('enable_tabs', 'off');
        $enable_thumbnails = $slider->getParam('enable_thumbnails', 'off');
        if ($enable_arrows == 'on' || $enable_bullets == 'on' || $enable_tabs == 'on' || $enable_thumbnails == 'on') {
            $using_navigation = true;
        }
        if (!empty($slides) && count($slides) > 0) {
            foreach ($slides as $key => $slide) {
                if (isset($slide['params']['state']) && $slide['params']['state'] != 'published') {
                    continue;
                }
                if (!isset($slide['id'])) {
                    continue;
                }
                $slide_counter++;
                $slide_id = $slide['id'];
                if (isset($slide['params']['kenburn_effect']) && $slide['params']['kenburn_effect'] == 'on') {
                    $using_kenburns = true;
                }
                if (!isset($slide['params']['image_source_type'])) {
                    $slide['params']['image_source_type'] = 'full';
                }
                if (isset($slide['params']['image']) && $slide['params']['image'] != '') {
                    //add infos of image to an array
                    $infos = array();
                    $urlImage = false;
                    switch ($slide['params']['background_type']) {
                        case 'streamyoutube':
                        case 'streaminstagram':
                        case 'streamvimeo':
                        case 'youtube':
                        case 'vimeo':
                            $using_videos = true;
                            break;
                    }
                    if (isset($slide['params']['image_id'])) {
                        $cur_img_id = $slide['params']['image_id'];
                        //get image sizes by ID
                        $urlImage = wp_get_attachment_image_src($slide['params']['image_id'], $slide['params']['image_source_type']);
                    }
                    if ($urlImage === false) {
                        $cur_img_id = RevSliderFunctionsWP::get_image_id_by_url($slide['params']['image']);
                        if ($cur_img_id !== false) {
                            $urlImage = wp_get_attachment_image_src($cur_img_id, $slide['params']['image_source_type']);
                        }
                    }
                    if ($urlImage !== false) {
                        $infos['id'] = $cur_img_id;
                        $file = get_attached_file($cur_img_id);
                        $infos['info'] = pathinfo($file);
                        if (file_exists($file)) {
                            $infos['size'] = filesize($file);
                            $infos['size-format'] = size_format($infos['size'], 2);
                            $img_size += $infos['size'];
                            if ($slide_counter == 1) {
                                $firstslide_size += $infos['size'];
                            }
                            if ($slide_counter == 1 || $slide_counter == 2 || $slide_counter == count($slides)) {
                                $smartslide_size += $infos['size'];
//.........这里部分代码省略.........
开发者ID:hathbanger,项目名称:squab,代码行数:101,代码来源:operations.class.php

示例2: change_slide_settings_5_1_1

 /**
  * change image id of all slides to 5.1.1
  * @since 5.1.1
  */
 public static function change_slide_settings_5_1_1($sliders = false)
 {
     $sr = new RevSlider();
     $sl = new RevSliderSlide();
     //$operations = new RevSliderOperations();
     if ($sliders === false) {
         //do it on all Sliders
         $sliders = $sr->getArrSliders(false);
     } else {
         $sliders = array($sliders);
     }
     if (!empty($sliders) && is_array($sliders)) {
         foreach ($sliders as $slider) {
             $slides = $slider->getSlides();
             $staticID = $sl->getStaticSlideID($slider->getID());
             if ($staticID !== false) {
                 $msl = new RevSliderSlide();
                 if (strpos($staticID, 'static_') === false) {
                     $staticID = 'static_' . $slider->getID();
                 }
                 $msl->initByID($staticID);
                 if ($msl->getID() !== '') {
                     $slides = array_merge($slides, array($msl));
                 }
             }
             if (!empty($slides) && is_array($slides)) {
                 foreach ($slides as $slide) {
                     //get image url, then get the image id and save it in image_id
                     $image_id = $slide->getParam('image_id', '');
                     $image = $slide->getParam('image', '');
                     $ml_id = '';
                     if ($image !== '') {
                         $ml_id = RevSliderFunctionsWP::get_image_id_by_url($image);
                     }
                     if ($image == '' && $image_id == '') {
                         continue;
                     }
                     //if we are a video and have no cover image, do nothing
                     if ($ml_id !== false && $ml_id !== $image_id) {
                         $urlImage = wp_get_attachment_image_src($ml_id, 'full');
                         $slide->setParam('image_id', $ml_id);
                         $slide->saveParams();
                     }
                 }
             }
         }
     }
 }
开发者ID:dawnthemes,项目名称:tkb,代码行数:52,代码来源:plugin-update.class.php

示例3: putCreativeLayer


//.........这里部分代码省略.........
                             $use_color = RevSliderFunctions::get_biggest_device_setting($static_styles['color'], $enabled_sizes);
                         } else {
                             $use_color = $static_styles['color'];
                         }
                         $def_val = (array) RevSliderFunctions::getVal($layer, 'deformation', array());
                         $color_trans = RevSliderFunctions::getVal($def_val, 'color-transparency', 1);
                         if ($color_trans != $dcot || $use_color != $dco) {
                             if ($color_trans > 0) {
                                 $color_trans *= 100;
                             }
                             $color_trans = intval($color_trans);
                             $use_color = RevSliderFunctions::hex2rgba($use_color, $color_trans);
                             $inline_styles .= ' color: ' . $use_color . ';';
                         }
                     }
                 }
                 if ($layer_2d_rotation !== 0) {
                     $do_rotation = true;
                 }
                 break;
             case 'image':
                 $additional = '';
                 $urlImage = RevSliderFunctions::getVal($layer, 'image_url');
                 $do_image_change = RevSliderFunctions::getVal($layer, 'image-size', 'auto');
                 $img_size = 'full';
                 switch ($do_image_change) {
                     case 'auto':
                         $img_size = $image_source_type;
                         break;
                     default:
                         $img_size = $do_image_change;
                         break;
                 }
                 $cur_img_id = RevSliderFunctionsWP::get_image_id_by_url($urlImage);
                 if ($img_size !== 'full') {
                     if ($cur_img_id !== false) {
                         $urlImage = wp_get_attachment_image_src($cur_img_id, $img_size);
                         $urlImage = $urlImage[0];
                     }
                 }
                 $img_w = '';
                 $img_h = '';
                 if ($cur_img_id !== false) {
                     $img_data = wp_get_attachment_metadata($cur_img_id);
                     if ($img_data !== false && !empty($img_data)) {
                         if ($img_size !== 'full') {
                             if (isset($img_data['sizes']) && isset($img_data['sizes'][$img_size])) {
                                 $img_w = $img_data['sizes'][$img_size]['width'];
                                 $img_h = $img_data['sizes'][$img_size]['height'];
                             }
                         }
                         if ($img_w == '' || $img_h == '') {
                             $img_w = $img_data['width'];
                             $img_h = $img_data['height'];
                         }
                         $additional .= ' width="' . $img_w . '" height="' . $img_h . '"';
                     }
                 }
                 $alt = '';
                 $alt_option = RevSliderFunctions::getVal($layer, 'alt_option', 'media_library');
                 switch ($alt_option) {
                     case 'media_library':
                         if ($cur_img_id !== false) {
                             $alt = get_post_meta($cur_img_id, '_wp_attachment_image_alt', true);
                         }
                         break;
开发者ID:surreal8,项目名称:wptheme,代码行数:67,代码来源:output.class.php


注:本文中的RevSliderFunctionsWP::get_image_id_by_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。