• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP image_downsize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中image_downsize函数的典型用法代码示例。如果您正苦于以下问题:PHP image_downsize函数的具体用法?PHP image_downsize怎么用?PHP image_downsize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: social_ring_get_first_image

function social_ring_get_first_image()
{
    global $post, $posts;
    if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-thumbnail');
        if ($thumbnail) {
            $image = $thumbnail[0];
        }
        // If that's not there, grab the first attached image
    } else {
        $files = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
        if ($files) {
            $keys = array_reverse(array_keys($files));
            $image = image_downsize($keys[0], 'thumbnail');
            $image = $image[0];
        }
    }
    //if there's no attached image, try to grab first image in content
    if (empty($image)) {
        ob_start();
        ob_end_clean();
        $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
        if (!empty($matches[1][0])) {
            $image = $matches[1][0];
        }
    }
    return $image;
}
开发者ID:ahsaeldin,项目名称:projects,代码行数:28,代码来源:library.php


示例2: eme_ical_single_event

function eme_ical_single_event($event, $title_format, $description_format) {
   global $eme_timezone;
   $title = eme_sanitize_ical (eme_replace_placeholders ( $title_format, $event, "text" ));
   $description = eme_sanitize_ical (eme_replace_placeholders ( $description_format, $event, "text" ));
   $html_description = eme_sanitize_ical (eme_replace_placeholders ( $description_format, $event, "html" ),1);

   $event_link = eme_event_url($event);
   $startstring=new ExpressiveDate($event['event_start_date']." ".$event['event_start_time'],$eme_timezone);
   $dtstartdate=$startstring->format("Ymd");
   $dtstarthour=$startstring->format("His");
   //$dtstart=$dtstartdate."T".$dtstarthour."Z";
   // we'll use localtime, so no "Z"
   $dtstart=$dtstartdate."T".$dtstarthour;
   if ($event['event_end_date'] == "")
      $event['event_end_date'] = $event['event_start_date'];
   if ($event['event_end_time'] == "")
      $event['event_end_time'] = $event['event_start_time'];
   $endstring=$event['event_end_date']." ".$event['event_end_time'];
   $endstring=new ExpressiveDate($event['event_end_date']." ".$event['event_end_time'],$eme_timezone);
   $dtenddate=$endstring->format("Ymd");
   $dtendhour=$endstring->format("His");
   //$dtend=$dtenddate."T".$dtendhour."Z";
   // we'll use localtime, so no "Z"
   $dtend=$dtenddate."T".$dtendhour;
   $tzstring = get_option('timezone_string');

   $res = "";
   $res .= "BEGIN:VEVENT\r\n";
   //DTSTAMP must be in UTC format, so adding "Z" as well
   $res .= "DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z\r\n";
   if ($event['event_properties']['all_day']) {
      // ical standard for an all day event: specify only the day, meaning
      // an 'all day' event is flagged as starting at the beginning of one day and lasting until the beginning of the next
      // so it is the same as adding "T000000" as time spec to the start/end datestring
      // But since it "ends" at the beginning of the next day, we should add 24 hours, otherwise the event ends one day too soon
      $dtenddate=$endstring->addOneDay()->format('Ymd');
      $res .= "DTSTART;VALUE=DATE:$dtstartdate\r\n";
      $res .= "DTEND;VALUE=DATE:$dtenddate\r\n";
   } else {
      $res .= "DTSTART;TZID=$tzstring:$dtstart\r\n";
      $res .= "DTEND;TZID=$tzstring:$dtend\r\n";
   }
   $res .= "UID:$dtstart-$dtend-".$event['event_id']."@".$_SERVER['SERVER_NAME']."\r\n";
   $res .= "SUMMARY:$title\r\n";
   $res .= "DESCRIPTION:$description\r\n";
   $res .= "X-ALT-DESC;FMTTYPE=text/html:$html_description\r\n";
   $res .= "URL:$event_link\r\n";
   $res .= "ATTACH:$event_link\r\n";
   if ($event['event_image_id']) {
      $thumb_array = image_downsize( $event['event_image_id'], get_option('eme_thumbnail_size') );
      $thumb_url = $thumb_array[0];
      $res .= "ATTACH:$thumb_url\r\n";
   }
   if (isset($event['location_id']) && $event['location_id']) {
      $location = eme_sanitize_ical (eme_replace_placeholders ( "#_LOCATION, #_ADDRESS, #_TOWN", $event, "text" ));
      $res .= "LOCATION:$location\r\n";
   }
   $res .= "END:VEVENT\r\n";
   return $res;
}
开发者ID:johnmanlove,项目名称:Bridgeland,代码行数:60,代码来源:eme_ical.php


示例3: circleflip_make_missing_intermediate_size

 /** generate new image sizes for old uploads
  * 
  * @param mixed $out
  * @param int $id
  * @param string|array $size
  * @return mixed
  */
 function circleflip_make_missing_intermediate_size($out, $id, $size)
 {
     $skip_sizes = array('full', 'large', 'medium', 'thumbnail', 'thumb');
     if (is_array($size) || in_array($size, $skip_sizes)) {
         return $out;
     }
     // the size exists and the attachment doesn't have a pre-generated file of that size
     // or the intermediate size defintion changed ( during development )
     if (circleflip_intermediate_size_exists($size) && (!circleflip_image_has_intermediate_size($id, $size) || circleflip_has_intermediate_size_changed($id, $size))) {
         // get info registerd by add_image_size
         $size_info = circleflip_get_intermediate_size_info($size);
         // get path to the original file
         $file_path = get_attached_file($id);
         // resize the image
         $resized_file = image_make_intermediate_size($file_path, $size_info['width'], $size_info['height'], $size_info['crop']);
         if ($resized_file) {
             // we have a resized image, get the attachment metadata and add the new size to it
             $metadata = wp_get_attachment_metadata($id);
             $metadata['sizes'][$size] = $resized_file;
             if (wp_update_attachment_metadata($id, $metadata)) {
                 // update succeded, call image_downsize again , DRY
                 return image_downsize($id, $size);
             }
         } else {
             // failed to generate the resized image
             // call image_downsize with `full` to prevent infinit loop
             return image_downsize($id, 'full');
         }
     }
     // pre-existing intermediate size
     return $out;
 }
开发者ID:purgesoftwares,项目名称:purges,代码行数:39,代码来源:WP-Make-Missing-Sizes.php


示例4: getImageThumbnail

 /**
  * @param string $ID The attachment ID to retrieve thumbnail from.
  *
  * @return bool|string  False on failure, URL to thumb on success.
  */
 private static function getImageThumbnail($ID)
 {
     $options = DG_Thumber::getOptions();
     $ret = false;
     if ($icon = image_downsize($ID, array($options['width'], $options['height']))) {
         $ret = $icon[0];
     }
     return $ret;
 }
开发者ID:WildCodeSchool,项目名称:projet-maison_ados_dreux,代码行数:14,代码来源:class-default-thumber.php


示例5: the_thumb

function the_thumb($size = "medium", $add = "")
{
    global $wpdb, $post;
    $thumb = $wpdb->get_row("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_parent = {$post->ID} AND post_mime_type LIKE 'image%' ORDER BY menu_order");
    if (!empty($thumb)) {
        $image = image_downsize($thumb->ID, $size);
        print "<img src='{$image[0]}' alt='{$thumb->post_title}' {$add} />";
    }
}
开发者ID:Ashleyotero,项目名称:oldest-old,代码行数:9,代码来源:functions.php


示例6: theme_gallery_lightbox

    /**
     * Post gGallery with lightbox ready for use.
     */
    function theme_gallery_lightbox($post_id)
    {
        global $post;
        $thumbnail_ID = get_post_thumbnail_id();
        $images = get_children(array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
        if ($images) {
            ?>

        <ul class="gallery-list" data-action="gallery-<?php 
            the_ID();
            ?>
" data-ui-component="gallery">

        <?php 
            foreach ($images as $attachment_id => $image) {
                if ($image->ID != $thumbnail_ID) {
                    $img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
                    //alt
                    if ($img_alt == '') {
                        $img_alt = $img_title;
                    }
                    $big_array = image_downsize($image->ID, 'full');
                    $img_url = $big_array[0];
                    ?>

            <li class="gallery-item" data-src="<?php 
                    echo $image_url;
                    ?>
" data-html="<div class='gallery-caption'><h4 class='text-inverse'><?php 
                    echo the_title();
                    ?>
</h4><?php 
                    echo the_content();
                    ?>
</div>">
                <img src="<?php 
                    echo $img_url;
                    ?>
" alt="<?php 
                    echo $img_alt;
                    ?>
" title="<?php 
                    echo $img_title;
                    ?>
" />
            </li>

            <?php 
                }
                ?>
            <?php 
            }
            ?>
        </ul>
        <?php 
        }
    }
开发者ID:jimbarrett147,项目名称:boilerplates,代码行数:60,代码来源:gallery.php


示例7: tevkori_get_sizes

/**
 * Return a source size attribute for an image from an array of values.
 *
 * @since 2.2.0
 *
 * @param int    $id   Image attachment ID.
 * @param string $size Optional. Name of image size. Default value: 'medium'.
 * @param array  $args {
 *     Optional. Arguments to retrieve posts.
 *
 *     @type array|string $sizes An array or string containing of size information.
 *     @type int          $width A single width value used in the default `sizes` string.
 * }
 * @return string|bool A valid source size value for use in a 'sizes' attribute or false.
 */
function tevkori_get_sizes($id, $size = 'medium', $args = null)
{
    // Try to get the image width from `$args` before calling `image_downsize()`.
    if (is_array($args) && !empty($args['width'])) {
        $img_width = (int) $args['width'];
    } elseif ($img = image_downsize($id, $size)) {
        $img_width = $img[1];
    }
    // Bail early if ``$image_width` isn't set.
    if (!$img_width) {
        return false;
    }
    // Set the image width in pixels.
    $img_width = $img_width . 'px';
    // Set up our default values.
    $defaults = array('sizes' => array(array('size_value' => '100vw', 'mq_value' => $img_width, 'mq_name' => 'max-width'), array('size_value' => $img_width)));
    $args = wp_parse_args($args, $defaults);
    /**
     * Filter arguments used to create 'sizes' attribute.
     *
     * @since 2.4.0
     *
     * @param array   $args  An array of arguments used to create a 'sizes' attribute.
     * @param int     $id    Post ID of the original image.
     * @param string  $size  Name of the image size being used.
     */
    $args = apply_filters('tevkori_image_sizes_args', $args, $id, $size);
    // If sizes is passed as a string, just use the string.
    if (is_string($args['sizes'])) {
        $size_list = $args['sizes'];
        // Otherwise, breakdown the array and build a sizes string.
    } elseif (is_array($args['sizes'])) {
        $size_list = '';
        foreach ($args['sizes'] as $size) {
            // Use 100vw as the size value unless something else is specified.
            $size_value = $size['size_value'] ? $size['size_value'] : '100vw';
            // If a media length is specified, build the media query.
            if (!empty($size['mq_value'])) {
                $media_length = $size['mq_value'];
                // Use max-width as the media condition unless min-width is specified.
                $media_condition = !empty($size['mq_name']) ? $size['mq_name'] : 'max-width';
                // If a media_length was set, create the media query.
                $media_query = '(' . $media_condition . ": " . $media_length . ') ';
            } else {
                // If not meda length was set, $media_query is blank.
                $media_query = '';
            }
            // Add to the source size list string.
            $size_list .= $media_query . $size_value . ', ';
        }
        // Remove the trailing comma and space from the end of the string.
        $size_list = substr($size_list, 0, -2);
    }
    // If $size_list is defined set the string, otherwise set false.
    return $size_list ? $size_list : false;
}
开发者ID:stanwmusic,项目名称:wp-tevko-responsive-images,代码行数:71,代码来源:wp-tevko-responsive-images.php


示例8: eazy_css_slider_image_size

function eazy_css_slider_image_size($downsize, $id, $size)
{
    if (!is_admin() || !get_current_screen() || 'edit' !== get_current_screen()->parent_base) {
        return $downsize;
    }
    remove_filter('image_downsize', __FUNCTION__, 10, 3);
    // settings can be thumbnail, medium, large, full
    $image = image_downsize($id, 'medium');
    add_filter('image_downsize', __FUNCTION__, 10, 3);
    return $image;
}
开发者ID:RobScottLLC,项目名称:eazy-css-slider,代码行数:11,代码来源:eazy_css_slider.php


示例9: nerdy_get_images

function nerdy_get_images($size = 'thumbnail', $limit = '0', $offset = '0')
{
    global $post;
    $images = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    if ($images) {
        $num_of_images = count($images);
        if ($offset > 0) {
            $start = $offset--;
        } else {
            $start = 0;
        }
        if ($limit > 0) {
            $stop = $limit + $start;
        } else {
            $stop = $num_of_images;
        }
        $i = 0;
        foreach ($images as $image) {
            if ($start <= $i and $i < $stop) {
                $img_title = $image->post_title;
                // title.
                $img_description = $image->post_content;
                // description.
                $img_caption = $image->post_excerpt;
                // caption.
                $img_url = wp_get_attachment_url($image->ID);
                // url of the full size image.
                $preview_array = image_downsize($image->ID, $size);
                $img_preview = $preview_array[0];
                // thumbnail or medium image to use for preview.
                ?>
            <li>
                <a href="<?php 
                echo $img_url;
                ?>
"><img src="<?php 
                echo $img_preview;
                ?>
" alt="<?php 
                echo $img_caption;
                ?>
" title="<?php 
                echo $img_title;
                ?>
"></a>
            </li>
            <?php 
            }
            $i++;
        }
    }
}
开发者ID:sputnick3k,项目名称:default-wordpress-theme,代码行数:52,代码来源:image-gallery.php


示例10: getImageTag

 function getImageTag($id, $alt, $title, $align, $size = 'medium', $attrs = array())
 {
     list($img_src, $width, $height) = image_downsize($id, $size);
     $hwstring = image_hwstring($width, $height);
     $class = 'align' . esc_attr($align) . ' size-' . esc_attr($size) . ' wp-image-' . $id;
     $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
     $attrs_fields = '';
     foreach ($attrs as $name => $attr) {
         $attrs_fields .= ' ' . $name . '="' . esc_attr($attr) . '" ';
     }
     $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title) . '" ' . $hwstring . 'class="' . $class . '" ' . $attrs_fields . ' />';
     return $html;
 }
开发者ID:AgnaldoJaws,项目名称:belavista-wp,代码行数:13,代码来源:class.admin.php


示例11: getImageSquareSize

 public function getImageSquareSize($img_id, $img_size)
 {
     if (preg_match_all('/(\\d+)x(\\d+)/', $img_size, $sizes)) {
         $exact_size = array('width' => isset($sizes[1][0]) ? $sizes[1][0] : '0', 'height' => isset($sizes[2][0]) ? $sizes[2][0] : '0');
     } else {
         $image_downsize = image_downsize($img_id, $img_size);
         $exact_size = array('width' => $image_downsize[1], 'height' => $image_downsize[2]);
     }
     if (isset($exact_size['width']) && (int) $exact_size['width'] !== (int) $exact_size['height']) {
         $img_size = (int) $exact_size['width'] > (int) $exact_size['height'] ? $exact_size['height'] . 'x' . $exact_size['height'] : $exact_size['width'] . 'x' . $exact_size['width'];
     }
     return $img_size;
 }
开发者ID:VitaAprel,项目名称:mynotebook,代码行数:13,代码来源:vc-single-image.php


示例12: get_audiotheme_playlist_track

/**
 * Convert a track into the format expected by the Cue plugin.
 *
 * @since 1.5.0
 *
 * @param int|WP_Post $post Post object or ID.
 * @return object Track object expected by Cue.
 */
function get_audiotheme_playlist_track($post = 0)
{
    $post = get_post($post);
    $track = new stdClass();
    $track->id = $post->ID;
    $track->artist = get_audiotheme_track_artist($post->ID);
    $track->audioUrl = get_audiotheme_track_file_url($post->ID);
    $track->title = get_the_title($post->ID);
    if ($thumbnail_id = get_audiotheme_track_thumbnail_id($post->ID)) {
        $size = apply_filters('cue_artwork_size', array(300, 300));
        $image = image_downsize($thumbnail_id, $size);
        $track->artworkUrl = $image[0];
    }
    return $track;
}
开发者ID:sewmyheadon,项目名称:audiotheme,代码行数:23,代码来源:playlist.php


示例13: argo_get_image_tag

/**
 * argo_get_image_tag(): Renders an <img /> tag for attachments, scaling it
 * to $size and guaranteeing that it's not wider than the content well.
 *
 * This is largely taken from get_image_tag() in wp-includes/media.php.
 */
function argo_get_image_tag($html, $id, $alt, $title, $align, $size)
{
    // Never allow an image wider than the LARGE_WIDTH
    if ($size == 'full') {
        list($img_src, $width, $height) = wp_get_attachment_image_src($id, $size);
        if ($width > LARGE_WIDTH) {
            $size = 'large';
        }
    }
    list($img_src, $width, $height) = image_downsize($id, $size);
    $hwstring = image_hwstring($width, $height);
    // XXX: may not need all these classes
    $class = 'align' . esc_attr($align) . ' size-' . esc_attr($size) . ' wp-image-' . $id;
    $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
    $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title) . '" ' . $hwstring . 'class="' . $class . '" />';
    return $html;
}
开发者ID:regancarver,项目名称:Argo,代码行数:23,代码来源:images.php


示例14: nerdy_project_slide_get_images

function nerdy_project_slide_get_images($size = 'thumbnail', $limit = '0', $offset = '0')
{
    global $post;
    $images = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    if ($images) {
        $num_of_images = count($images);
        if ($offset > 0) {
            $start = $offset--;
        } else {
            $start = 0;
        }
        if ($limit > 0) {
            $stop = $limit + $start;
        } else {
            $stop = $num_of_images;
        }
        $i = 0;
        foreach ($images as $image) {
            if ($start <= $i and $i < $stop) {
                $img_title = $image->post_title;
                // title.
                $img_description = $image->post_content;
                // description.
                $img_caption = $image->post_excerpt;
                // caption.
                $img_url = wp_get_attachment_url($image->ID);
                // url of the full size image.
                $preview_array = image_downsize($image->ID, $size);
                $img_preview = $preview_array[0];
                // thumbnail or medium image to use for preview.
                ///////////////////////////////////////////////////////////
                // This is where you'd create your custom image/link/whatever tag using the variables above.
                // This is an example of a basic image tag using this method.
                ?>
        <div><img src="<?php 
                echo $img_preview;
                ?>
" /></div>
			<?php 
                // End custom image tag. Do not edit below here.
                ///////////////////////////////////////////////////////////
            }
            $i++;
        }
    }
}
开发者ID:andrew-ok7,项目名称:base_theme,代码行数:46,代码来源:post-types.php


示例15: get_src

 function get_src($size = '')
 {
     if (isset($this->abs_url)) {
         return $this->abs_url;
     }
     if ($size && is_string($size) && isset($this->sizes[$size])) {
         $image = image_downsize($this->ID, $size);
         return reset($image);
     }
     if (!isset($this->file) && isset($this->_wp_attached_file)) {
         $this->file = $this->_wp_attached_file;
     }
     if (!isset($this->file)) {
         return false;
     }
     $dir = wp_upload_dir();
     $base = $dir["baseurl"];
     return trailingslashit($base) . $this->file;
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:19,代码来源:timber-image.php


示例16: tevkori_get_sizes

/**
 * Return a source size attribute for an image from an array of values.
 *
 * @since 2.2.0
 *
 * @param int $id 			Image attacment ID.
 * @param string $size	Optional. Name of image size. Default value: 'thumbnail'.
 * @param array $args {
 *     Optional. Arguments to retrieve posts.
 *
 *     @type array|string 	$sizes     An array or string containing of size information.
 * }
 * @return string|bool A valid source size value for use in a 'sizes' attribute or false.
 */
function tevkori_get_sizes($id, $size = 'thumbnail', $args = null)
{
    // See which image is being returned and bail if none is found
    if (!($image = image_downsize($id, $size))) {
        return false;
    }
    // Get the image width
    $img_width = $image[1] . 'px';
    // Set up our default values
    $defaults = array('sizes' => array(array('size_value' => '100vw', 'mq_value' => $img_width, 'mq_name' => 'max-width'), array('size_value' => $img_width)));
    $args = wp_parse_args($args, $defaults);
    // If sizes is passed as a string, just use the string
    if (is_string($args['sizes'])) {
        $size_list = $args['sizes'];
        // Otherwise, breakdown the array and build a sizes string
    } elseif (is_array($args['sizes'])) {
        $size_list = '';
        foreach ($args['sizes'] as $size) {
            // Use 100vw as the size value unless something else is specified.
            $size_value = $size['size_value'] ? $size['size_value'] : '100vw';
            // If a media length is specified, build the media query.
            if (!empty($size['mq_value'])) {
                $media_length = $size['mq_value'];
                // Use max-width as the media condition unless min-width is specified.
                $media_condition = !empty($size['mq_name']) ? $size['mq_name'] : 'max-width';
                // If a media_length was set, create the media query.
                $media_query = '(' . $media_condition . ": " . $media_length . ') ';
            } else {
                // If not meda length was set, $media_query is blank
                $media_query = '';
            }
            // Add to the source size list string.
            $size_list .= $media_query . $size_value . ', ';
        }
        // Remove the trailing comma and space from the end of the string.
        $size_list = substr($size_list, 0, -2);
    }
    // If $size_list is defined set the string, otherwise set false.
    $size_string = $size_list ? $size_list : false;
    return $size_string;
}
开发者ID:Clear-Space,项目名称:meritq,代码行数:55,代码来源:wp-tevko-responsive-images.php


示例17: wphidpi_image_downsize

 function wphidpi_image_downsize($out, $id, $size)
 {
     $orig_size = $size;
     if (!wphidpi_enabled()) {
         return false;
     }
     if (is_array($size)) {
         foreach ($size as &$component) {
             $component = intval($component) * 2;
         }
     } else {
         if (strtolower($size) != 'full') {
             $size = $size . wphidpi_suffix();
         }
     }
     remove_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
     $downsize = image_downsize($id, $size);
     add_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
     // If downsize isn't false  and this is an intermediate
     if ($downsize && $downsize[3]) {
         $downsize[1] = intval($downsize[1]) / 2;
         $downsize[2] = intval($downsize[2]) / 2;
     } else {
         if ($downsize && $size != 'full') {
             // Full sized but no 2x, serve with original dimensions but full sized source
             $original_url = $downsize[0];
             remove_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
             $downsize_orig = image_downsize($id, $orig_size);
             add_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
             if ($downsize_orig) {
                 $downsize = $downsize_orig;
                 $downsize[0] = $original_url;
             }
         }
     }
     return $downsize;
 }
开发者ID:kidfiction,项目名称:wp-hidpi-images,代码行数:37,代码来源:wp-hidpi-images.php


示例18: wppb_front_end_register


//.........这里部分代码省略.........
                                            $target_path = $target_path . 'userID_' . $new_user . '_attachment_' . $finalFileName;
                                            if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) {
                                                //$upFile = get_bloginfo('home').'/'.$target_path;
                                                $upFile = $wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $new_user . '_attachment_' . $finalFileName;
                                                add_user_meta($new_user, $value['item_metaName'], $upFile);
                                                $pictureUpload = 'yes';
                                            }
                                        }
                                    }
                                    break;
                                case "avatar":
                                    $uploadedfile = $value['item_type'] . $value['id'];
                                    $wpUploadPath = wp_upload_dir();
                                    // Array of key => value pairs
                                    $target_path_original = $wpUploadPath['basedir'] . "/profile_builder/avatars/";
                                    $fileName = $_FILES[$uploadedfile]['name'];
                                    $finalFileName = '';
                                    for ($i = 0; $i < strlen($fileName); $i++) {
                                        if ($fileName[$i] == "'") {
                                            $finalFileName .= '`';
                                        } elseif ($fileName[$i] == ' ') {
                                            $finalFileName .= '_';
                                        } else {
                                            $finalFileName .= $fileName[$i];
                                        }
                                    }
                                    $fileName = $finalFileName;
                                    $target_path = $target_path_original . 'userID_' . $new_user . '_originalAvatar_' . $fileName;
                                    /* when trying to upload file, be sure it's one of the accepted image file-types */
                                    if (($_FILES[$uploadedfile]['type'] == 'image/jpeg' || $_FILES[$uploadedfile]['type'] == 'image/jpg' || $_FILES[$uploadedfile]['type'] == 'image/png' || $_FILES[$uploadedfile]['type'] == 'image/bmp' || $_FILES[$uploadedfile]['type'] == 'image/pjpeg' || $_FILES[$uploadedfile]['type'] == 'image/x-png') && ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0)) {
                                        $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null);
                                        $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit');
                                        $attach_id = wp_insert_attachment($attachment, $target_path);
                                        $upFile = image_downsize($attach_id, 'thumbnail');
                                        $upFile = $upFile[0];
                                        //if file upload succeded
                                        if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) {
                                            add_user_meta($new_user, $value['item_metaName'], $upFile);
                                            wppb_resize_avatar($new_user);
                                            $avatarUpload = 'yes';
                                        } else {
                                            $avatarUpload = 'no';
                                        }
                                    }
                                    if ($_FILES[$uploadedfile]['type'] == '') {
                                        $avatarUpload = 'yes';
                                    }
                                    break;
                            }
                        }
                    }
                    // if admin approval is activated, then block the user untill he gets approved
                    $wppb_generalSettings = get_option('wppb_general_settings', 'not_found');
                    if ($wppb_generalSettings != 'not_found') {
                        if ($wppb_generalSettings['adminApproval'] == 'yes') {
                            wp_set_object_terms($new_user, array('unapproved'), 'user_status', false);
                            clean_object_term_cache($new_user, 'user_status');
                        }
                    }
                    // send an email to the admin, and - if selected - to the user also.
                    $bloginfo = get_bloginfo('name');
                    $sentEmailStatus = wppb_notify_user_registration_email($bloginfo, esc_attr($_POST['user_name']), esc_attr($_POST['email']), $_POST['send_credentials_via_email'], $_POST['passw1'], $wppb_generalSettings['adminApproval']);
                }
            } elseif (is_multisite()) {
                //validate username and email
                $validationRes = wpmu_validate_user_signup($userdata['user_login'], $userdata['user_email']);
开发者ID:par-orillonsoft,项目名称:elearning-wordpress,代码行数:67,代码来源:wppb.register.php


示例19: sizesInForm

 /**
  * Add the custom sizes to the image sizes in article edition
  * 
  * @access public
  * @param array $form_fields
  * @param object $post
  * @return void
  * @author Nicolas Juen
  * @author Additional Image Sizes (zui)
  */
 public function sizesInForm($form_fields, $post)
 {
     // Protect from being view in Media editor where there are no sizes
     if (isset($form_fields['image-size'])) {
         $out = NULL;
         $size_names = array();
         $sizes_custom = get_option(SIS_OPTION);
         if (is_array($sizes_custom)) {
             foreach ($sizes_custom as $key => $value) {
                 if (isset($value['s']) && $value['s'] == 1) {
                     $size_names[$key] = $this->_getThumbnailName($key);
                 }
             }
         }
         foreach ($size_names as $size => $label) {
             $downsize = image_downsize($post->ID, $size);
             // is this size selectable?
             $enabled = $downsize[3] || 'full' == $size;
             $css_id = "image-size-{$size}-{$post->ID}";
             // We must do a clumsy search of the existing html to determine is something has been checked yet
             if (FALSE === strpos('checked="checked"', $form_fields['image-size']['html'])) {
                 if (empty($check)) {
                     $check = get_user_setting('imgsize');
                 }
                 // See if they checked a custom size last time
                 $checked = '';
                 // if this size is the default but that's not available, don't select it
                 if ($size == $check || str_replace(" ", "", $size) == $check) {
                     if ($enabled) {
                         $checked = " checked='checked'";
                     } else {
                         $check = '';
                     }
                 } elseif (!$check && $enabled && 'thumbnail' != $size) {
                     // if $check is not enabled, default to the first available size that's bigger than a thumbnail
                     $check = $size;
                     $checked = " checked='checked'";
                 }
             }
             $html = "<div class='image-size-item' style='min-height: 50px; margin-top: 18px;'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
             $html .= "<label for='{$css_id}'>{$label}</label>";
             // only show the dimensions if that choice is available
             if ($enabled) {
                 $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
             }
             $html .= '</div>';
             $out .= $html;
         }
         $form_fields['image-size']['html'] .= $out;
     }
     // End protect from Media editor
     return $form_fields;
 }
开发者ID:sriram911,项目名称:pls,代码行数:63,代码来源:class.admin.php


示例20: parseTemplate

function parseTemplate($id, $type, $template, $orig_filename, $icon = "")
{
    DebugEcho("parseTemplate - before: {$template}");
    $size = 'medium';
    /* we check template for thumb, thumbnail, large, full and use that as
       size. If not found, we default to medium */
    if ($type == 'image') {
        $sizes = array('thumbnail', 'medium', 'large');
        $hwstrings = array();
        $widths = array();
        $heights = array();
        for ($i = 0; $i < count($sizes); $i++) {
            list($img_src[$i], $widths[$i], $heights[$i]) = image_downsize($id, $sizes[$i]);
            $hwstrings[$i] = image_hwstring($widths[$i], $heights[$i]);
        }
    }
    $attachment = get_post($id);
    $the_parent = get_post($attachment->post_parent);
    $uploadDir = wp_upload_dir();
    $fileName = basename($attachment->guid);
    $absFileName = $uploadDir['path'] . '/' . $fileName;
    $relFileName = str_replace(ABSPATH, '', $absFileName);
    $fileLink = wp_get_attachment_url($id);
    $pageLink = get_attachment_link($id);
    $template = str_replace('{TITLE}', $attachment->post_title, $template);
    $template = str_replace('{ID}', $id, $template);
    if ($type == 'image') {
        $template = str_replace('{THUMBNAIL}', $img_src[0], $template);
        $template = str_replace('{THUMB}', $img_src[0], $template);
        $template = str_replace('{MEDIUM}', $img_src[1], $template);
        $template = str_replace('{LARGE}', $img_src[2], $template);
        $template = str_replace('{THUMBWIDTH}', $widths[0] . 'px', $template);
        $template = str_replace('{THUMBHEIGHT}', $heights[0] . 'px', $template);
        $template = str_replace('{MEDIUMWIDTH}', $widths[1] . 'px', $template);
        $template = str_replace('{MEDIUMHEIGHT}', $heights[1] . 'px', $template);
        $template = str_replace('{LARGEWIDTH}', $widths[2] . 'px', $template);
        $template = str_replace('{LARGEHEIGHT}', $heights[2] . 'px', $template);
    }
    $template = str_replace('{FULL}', $fileLink, $template);
    $template = str_replace('{FILELINK}', $fileLink, $template);
    $template = str_replace('{PAGELINK}', $pageLink, $template);
    $template = str_replace('{FILENAME}', $orig_filename, $template);
    $template = str_replace('{IMAGE}', $fileLink, $template);
    $template = str_replace('{URL}', $fileLink, $template);
    $template = str_replace('{RELFILENAME}', $relFileName, $template);
    $template = str_replace('{POSTTITLE}', $the_parent->post_title, $template);
    $template = str_replace('{ICON}', $icon, $template);
    DebugEcho("parseTemplate - after: {$template}");
    return $template . '<br />';
}
开发者ID:donwea,项目名称:nhap.org,代码行数:50,代码来源:postie-functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP image_edit_apply_changes函数代码示例发布时间:2022-05-15
下一篇:
PHP image_check_memory_usage函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap