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

PHP get_post_mime_type函数代码示例

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

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



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

示例1: hybrid_get_content_template

/**
 * Loads a post content template based off the post type and/or the post format.  This functionality is 
 * not feasible with the WordPress get_template_part() function, so we have to rely on some custom logic 
 * and locate_template().
 *
 * Note that using this function assumes that you're creating a content template to handle attachments. 
 * This filter must be removed since we're bypassing the WP template hierarchy and focusing on templates 
 * specific to the content.
 *
 * @since  1.6.0
 * @access public
 * @return string
 */
function hybrid_get_content_template()
{
    /* Set up an empty array and get the post type. */
    $templates = array();
    $post_type = get_post_type();
    /* Assume the theme developer is creating an attachment template. */
    if ('attachment' === $post_type) {
        remove_filter('the_content', 'prepend_attachment');
        $mime_type = get_post_mime_type();
        list($type, $subtype) = false !== strpos($mime_type, '/') ? explode('/', $mime_type) : array($mime_type, '');
        $templates[] = "content-attachment-{$type}.php";
        $templates[] = "content/attachment-{$type}.php";
    }
    /* If the post type supports 'post-formats', get the template based on the format. */
    if (post_type_supports($post_type, 'post-formats')) {
        /* Get the post format. */
        $post_format = get_post_format() ? get_post_format() : 'standard';
        /* Template based off post type and post format. */
        $templates[] = "content-{$post_type}-{$post_format}.php";
        $templates[] = "content/{$post_type}-{$post_format}.php";
        /* Template based off the post format. */
        $templates[] = "content-{$post_format}.php";
        $templates[] = "content/{$post_format}.php";
    }
    /* Template based off the post type. */
    $templates[] = "content-{$post_type}.php";
    $templates[] = "content/{$post_type}.php";
    /* Fallback 'content.php' template. */
    $templates[] = 'content.php';
    $templates[] = 'content/content.php';
    /* Allow devs to filter the content template hierarchy. */
    $templates = apply_filters('hybrid_content_template_hierarchy', $templates);
    /* Apply filters and return the found content template. */
    include apply_filters('hybrid_content_template', locate_template($templates, false, false));
}
开发者ID:highergroundstudio,项目名称:hybrid-core,代码行数:48,代码来源:template.php


示例2: sfc_media_find_images

function sfc_media_find_images($post, $content = '')
{
    if (empty($content)) {
        $content = apply_filters('the_content', $post->post_content);
    }
    $images = array();
    // we get the post thumbnail, put it first in the image list
    if (current_theme_supports('post-thumbnails') && has_post_thumbnail($post->ID)) {
        $thumbid = get_post_thumbnail_id($post->ID);
        $att = wp_get_attachment_image_src($thumbid, 'full');
        if (!empty($att[0])) {
            $images[] = $att[0];
        }
    }
    if (is_attachment() && preg_match('!^image/!', get_post_mime_type($post))) {
        $images[] = wp_get_attachment_url($post->ID);
    }
    // now search for images in the content itself
    if (preg_match_all('/<img\\s+(.+?)>/i', $content, $matches)) {
        foreach ($matches[1] as $match) {
            foreach (wp_kses_hair($match, array('http')) as $attr) {
                $img[strtolower($attr['name'])] = $attr['value'];
            }
            if (isset($img['src'])) {
                if (!isset($img['class']) || isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude', array('wp-smiley')))) {
                    // ignore smilies
                    if (!in_array($img['src'], $images) && strpos($img['src'], 'fbcdn.net') === false && strpos($img['src'], '/plugins/') === false) {
                        $images[] = $img['src'];
                    }
                }
            }
        }
    }
    return $images;
}
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:35,代码来源:sfc-media.php


示例3: wp_generate_attachment_metadata

 public function wp_generate_attachment_metadata($metadata, $attachment_id)
 {
     $attachment = get_attached_file($attachment_id);
     if (!preg_match('!^image/!', get_post_mime_type($attachment_id)) || !file_is_displayable_image($attachment)) {
         return $metadata;
     }
     $image_sizes = Helper::get_image_sizes();
     foreach ($image_sizes as $size_name => $size_attributes) {
         if (!empty($metadata['sizes'][$size_name])) {
             continue;
         }
         $image = wp_get_image_editor($attachment);
         if (is_wp_error($image)) {
             continue;
         }
         $resized = $image->resize($size_attributes['width'], $size_attributes['height'], $size_attributes['crop']);
         $image_size = $image->get_size();
         if (!is_wp_error($resized) && !empty($image_size)) {
             $filename = wp_basename($image->generate_filename());
             $extension = pathinfo($filename, PATHINFO_EXTENSION);
             $mime_type = $this->get_mime_type($extension);
             $metadata['sizes'][$size_name] = array('file' => $filename, 'width' => $image_size['width'], 'height' => $image_size['height'], 'mime-type' => $mime_type);
         }
     }
     return $metadata;
 }
开发者ID:brutalenemy666,项目名称:carbon-image-library,代码行数:26,代码来源:WP_Media.php


示例4: should_resize

 /**
  * Check whether Image should be resized or not
  *
  * @param string $params
  * @param string $action
  *
  * @return bool
  */
 private function should_resize($id = '')
 {
     //If resizing not enabled, or if both max width and height is set to 0, return
     if (!$this->resize_enabled || $this->max_w == 0 && $this->max_h == 0) {
         return false;
     }
     $file_path = get_attached_file($id);
     if (!empty($file_path)) {
         // Skip: if "noresize" is included in the filename, Thanks to Imsanity
         if (strpos($file_path, 'noresize') !== false) {
             return false;
         }
         //If file doesn't exists, return
         if (!file_exists($file_path)) {
             return false;
         }
     }
     //Check for a supported mime type
     global $wpsmushit_admin;
     //Get image mime type
     $mime = get_post_mime_type($id);
     $mime_supported = in_array($mime, $wpsmushit_admin->mime_types);
     //If type of upload doesn't matches the criteria return
     if (!empty($mime) && !($mime_supported = apply_filters('wp_smush_resmush_mime_supported', $mime_supported, $mime))) {
         return false;
     }
     //Check if already resized
     $resize_meta = get_post_meta($id, WP_SMUSH_PREFIX . 'resize_savings', true);
     if (!empty($resize_meta)) {
         return false;
     }
     return true;
 }
开发者ID:qhuit,项目名称:alejandra,代码行数:41,代码来源:class-wp-smush-resize.php


示例5: compress_attachment

 public function compress_attachment($metadata, $attachment_id)
 {
     $mime_type = get_post_mime_type($attachment_id);
     $tiny_metadata = new Tiny_Metadata($attachment_id);
     if ($this->compressor === null || strpos($mime_type, 'image/') !== 0) {
         return $metadata;
     }
     $path_info = pathinfo($metadata['file']);
     $upload_dir = wp_upload_dir();
     $prefix = $upload_dir['basedir'] . '/' . $path_info['dirname'] . '/';
     if (!$tiny_metadata->is_compressed()) {
         try {
             $response = $this->compressor->compress_file("{$prefix}{$path_info['basename']}");
             $tiny_metadata->add_response($response);
         } catch (Tiny_Exception $e) {
             $tiny_metadata->add_exception($e);
         }
     }
     $settings = $this->settings->get_sizes();
     foreach ($metadata['sizes'] as $size => $info) {
         if (isset($settings[$size]) && $settings[$size]['tinify'] && !$tiny_metadata->is_compressed($size)) {
             try {
                 $response = $this->compressor->compress_file("{$prefix}{$info['file']}");
                 $tiny_metadata->add_response($response, $size);
             } catch (Tiny_Exception $e) {
                 $tiny_metadata->add_exception($e, $size);
             }
         }
     }
     $tiny_metadata->update();
     return $metadata;
 }
开发者ID:EaseCloud,项目名称:easecloud,代码行数:32,代码来源:class-tiny-plugin.php


示例6: render_file

    function render_file($id = null)
    {
        if (!$id) {
            echo "";
            return;
        }
        // vars
        $file_src = wp_get_attachment_url($id);
        preg_match("~[^/]*\$~", $file_src, $file_name);
        $class = "active";
        ?>
		<ul class="hl">
			<li data-mime="<?php 
        echo get_post_mime_type($id);
        ?>
">
				<img class="acf-file-icon" src="<?php 
        echo wp_mime_type_icon($id);
        ?>
" alt=""/>
			</li>
			<li>
				<span class="acf-file-name"><?php 
        echo $file_name[0];
        ?>
</span><br />
				<a href="javascript:;" class="acf-file-delete"><?php 
        _e('Remove File', 'acf');
        ?>
</a>
			</li>
		</ul>
		<?php 
    }
开发者ID:rigelstpierre,项目名称:Everlovin-Press,代码行数:34,代码来源:file.php


示例7: wp_generate_attachment_metadata

/**
 * wp_generate_attachment_metadata() - Generate post Image attachment Metadata
 *
 * @package WordPress
 * @internal Missing Long Description
 * @param	int		$attachment_id	Attachment Id to process
 * @param	string	$file	Filepath of the Attached image
 * @return	mixed			Metadata for attachment
 *
 */
function wp_generate_attachment_metadata($attachment_id, $file)
{
    $attachment = get_post($attachment_id);
    $metadata = array();
    if (preg_match('!^image/!', get_post_mime_type($attachment)) && file_is_displayable_image($file)) {
        $imagesize = getimagesize($file);
        $metadata['width'] = $imagesize[0];
        $metadata['height'] = $imagesize[1];
        list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
        $metadata['hwstring_small'] = "height='{$uheight}' width='{$uwidth}'";
        $metadata['file'] = $file;
        // make thumbnails and other intermediate sizes
        $sizes = array('thumbnail', 'medium');
        $sizes = apply_filters('intermediate_image_sizes', $sizes);
        foreach ($sizes as $size) {
            $resized = image_make_intermediate_size($file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop"));
            if ($resized) {
                $metadata['sizes'][$size] = $resized;
            }
        }
        // fetch additional metadata from exif/iptc
        $image_meta = wp_read_image_metadata($file);
        if ($image_meta) {
            $metadata['image_meta'] = $image_meta;
        }
    }
    return apply_filters('wp_generate_attachment_metadata', $metadata);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:38,代码来源:image.php


示例8: grayscale_check_grayscale_image

function grayscale_check_grayscale_image($metadata, $attachment_id)
{
    global $_wp_additional_image_sizes;
    $attachment = get_post($attachment_id);
    if (preg_match('!image!', get_post_mime_type($attachment))) {
        require_once 'class-grayscale-image-editor.php';
        foreach ($_wp_additional_image_sizes as $size => $size_data) {
            if (isset($size_data['grayscale']) && $size_data['grayscale']) {
                if (is_array($metadata['sizes']) && isset($metadata['sizes'][$size])) {
                    $file = pathinfo(get_attached_file($attachment_id));
                    $filename = $file['dirname'] . '/' . $metadata['sizes'][$size]['file'];
                    $metadata['sizes'][$size . '-gray'] = $metadata['sizes'][$size];
                } else {
                    // this size has no image attached, probably because the original is too small
                    // create the grayscale image from the original file
                    $file = wp_upload_dir();
                    $filename = $file['basedir'] . '/' . $metadata['file'];
                    $metadata['sizes'][$size . '-gray'] = array('width' => $metadata['width'], 'height' => $metadata['height']);
                }
                $image = new Grayscale_Image_Editor($filename);
                $image->load();
                $image->make_grayscale();
                $result = $image->save($image->generate_filename('gray'));
                $metadata['sizes'][$size . '-gray']['file'] = $result['file'];
            }
        }
    }
    return $metadata;
}
开发者ID:jeffhertzler,项目名称:grayscale,代码行数:29,代码来源:grayscale.php


示例9: cherry_attachment_is_video

/**
 * Check if the attachment is a 'video'.
 *
 * @author Justin Tadlock <[email protected]>
 * @author Cherry Team <[email protected]>
 * @since  4.0.0
 * @param  int   $post_id Attachment ID.
 * @return bool
 */
function cherry_attachment_is_video($post_id = null)
{
    $post_id = null === $post_id ? get_the_ID() : $post_id;
    $mime_type = get_post_mime_type($post_id);
    list($type, $subtype) = false !== strpos($mime_type, '/') ? explode('/', $mime_type) : array($mime_type, '');
    return 'video' === $type ? true : false;
}
开发者ID:roberto-alarcon,项目名称:Neuroglobal,代码行数:16,代码来源:template-media.php


示例10: compress

 private function compress($metadata, $attachment_id)
 {
     $mime_type = get_post_mime_type($attachment_id);
     $tiny_metadata = new Tiny_Metadata($attachment_id, $metadata);
     if ($this->settings->get_compressor() === null || strpos($mime_type, 'image/') !== 0) {
         return array($tiny_metadata, null);
     }
     $success = 0;
     $failed = 0;
     $compressor = $this->settings->get_compressor();
     $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
     $uncompressed_sizes = $tiny_metadata->get_uncompressed_sizes($active_tinify_sizes);
     foreach ($uncompressed_sizes as $uncompressed_size) {
         try {
             $tiny_metadata->add_request($uncompressed_size);
             $tiny_metadata->update();
             $resize = $tiny_metadata->is_resizable($uncompressed_size) ? $this->settings->get_resize_options() : false;
             $response = $compressor->compress_file($tiny_metadata->get_filename($uncompressed_size), $resize);
             $tiny_metadata->add_response($response, $uncompressed_size);
             $tiny_metadata->update();
             $success++;
         } catch (Tiny_Exception $e) {
             $tiny_metadata->add_exception($e, $uncompressed_size);
             $tiny_metadata->update();
             $failed++;
         }
     }
     return array($tiny_metadata, array('success' => $success, 'failed' => $failed));
 }
开发者ID:gasbriones,项目名称:bacare,代码行数:29,代码来源:class-tiny-plugin.php


示例11: __addRoutes

 /**
  * Adds all routes to the existing HTTP API instance
  */
 protected function __addRoutes()
 {
     // Regenerate all sizes for all images
     $this->http_api->post('regenerate-all(/)', function () {
         // Set time limit of 30 minutes
         set_time_limit(60 * 30);
         $response = [];
         $query = new \WP_Query(['fields' => 'ids', 'post_type' => 'attachment', 'post_status' => 'inherit', 'numberposts' => -1]);
         if ($query->posts) {
             foreach ($query->posts as $id) {
                 if (strpos(get_post_mime_type($id), 'image/') !== false) {
                     $image = new Image($id);
                     $response[] = ['id' => $id, 'status' => $image->generateAllSizes()];
                 }
             }
         }
         return $response;
     });
     // Returns status about all sizes or a single one, for a single image
     $this->http_api->get(':id/status(/:size)(/)', function ($id, $size = null) {
         $image = new Image($id);
         return $image->getStatus($size);
     });
     // Generate all sizes for a single image
     $this->http_api->post(':id/generate-all(/)', function ($id) {
         $image = new Image($id);
         return $image->generateAllSizes();
     });
     // Generate a single image size
     $this->http_api->post(':id/generate/:size(/)', function ($id, $size) {
         $image = new Image($id);
         return $image->generateSize($size);
     });
 }
开发者ID:ponticlaro,项目名称:bebop-media,代码行数:37,代码来源:HttpApi.php


示例12: hybrid_attachment_is_video

/**
 * Checks if the current post has a mime type of 'video'.
 *
 * @since  1.6.0
 * @access public
 * @param  int    $post_id
 * @return bool
 */
function hybrid_attachment_is_video($post_id = 0)
{
    $post_id = empty($post_id) ? get_the_ID() : $post_id;
    $mime = get_post_mime_type($post_id);
    $mime_type = explode('/', $mime);
    return 'video' == array_shift($mime_type) ? true : false;
}
开发者ID:enamakel,项目名称:steven.pw-theme,代码行数:15,代码来源:wish-list.php


示例13: stormbringer_body_class

/**
 * Body Class - Thanks to Theme Hyprid (http://themehybrid.com/)
 */
function stormbringer_body_class($classes = '')
{
    global $wp_query;
    global $current_user;
    // User role
    $current_user->ID;
    $user = new WP_User($current_user->ID);
    // $user->roles
    foreach ($user->roles as $role) {
        $classes[] = 'role-' . $role;
    }
    /* Text direction (which direction does the text flow). */
    $classes[] = 'wordpress';
    $classes[] = get_bloginfo('text_direction');
    $classes[] = get_locale();
    /* Check if the current theme is a parent or child theme. */
    $classes[] = is_child_theme() ? 'child-theme' : 'parent-theme';
    /* Multisite check adds the 'multisite' class and the blog ID. */
    if (is_multisite()) {
        $classes[] = 'multisite';
        $classes[] = 'blog-' . get_current_blog_id();
    }
    /* Date classes. */
    $time = time() + get_option('gmt_offset') * 3600;
    $classes[] = strtolower(gmdate('\\yY \\mm \\dd \\hH l', $time));
    /* Is the current user logged in. */
    $classes[] = is_user_logged_in() ? 'logged-in' : 'logged-out';
    /* WP admin bar. */
    if (is_admin_bar_showing()) {
        $classes[] = 'admin-bar';
    }
    /* Merge base contextual classes with $classes. */
    $classes = array_merge($classes, stormbringer_get_context());
    /* Singular post (post_type) classes. */
    if (is_singular()) {
        /* Get the queried post object. */
        $post = get_queried_object();
        /* Checks for custom template. */
        $template = str_replace(array("{$post->post_type}-template-", "{$post->post_type}-", '.php'), '', get_post_meta(get_queried_object_id(), "_wp_{$post->post_type}_template", true));
        if (!empty($template)) {
            $classes[] = "{$post->post_type}-template-{$template}";
        }
        /* Post format. */
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
            $post_format = get_post_format(get_queried_object_id());
            $classes[] = empty($post_format) || is_wp_error($post_format) ? "{$post->post_type}-format-standard" : "{$post->post_type}-format-{$post_format}";
        }
        /* Attachment mime types. */
        if (is_attachment()) {
            foreach (explode('/', get_post_mime_type()) as $type) {
                $classes[] = "attachment-{$type}";
            }
        }
    }
    /* Paged views. */
    if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
        $classes[] = 'paged paged-' . intval($page);
    }
    return $classes;
}
开发者ID:nicomollet,项目名称:stormbringer,代码行数:63,代码来源:bodyclass.php


示例14: bpmn_media_to_shortcode

function bpmn_media_to_shortcode($html, $id, $attachment)
{
    $mime = get_post_mime_type($id);
    if ($mime == 'application/bpmn+xml') {
        $html = '[bpmn url="' . $attachment['url'] . '"]';
    }
    return $html;
}
开发者ID:nagyistoce,项目名称:bpmn-io_wp-plugin,代码行数:8,代码来源:shortcode.php


示例15: bpmn_media_to_editor

function bpmn_media_to_editor($html, $id, $attachment)
{
    $mime = get_post_mime_type($id);
    if ($mime == 'application/bpmn+xml') {
        $html = bpmnio_file_html($attachment['url']);
    }
    return $html;
}
开发者ID:quoka,项目名称:bpmn-io,代码行数:8,代码来源:bpmn.io_importer.php


示例16: jd_is_svg

function jd_is_svg($id)
{
    if (!is_numeric($id)) {
        return false;
    }
    $id = (int) $id;
    return get_post_mime_type($id) == 'image/svg+xml' ? true : false;
}
开发者ID:jessedyck,项目名称:Pinned-Tab-Icon,代码行数:8,代码来源:pinned-tab-icon.php


示例17: batch_update_image_tags

function batch_update_image_tags($is_update)
{
    $total = 0;
    $created = 0;
    $updated = 0;
    $deleted = 0;
    $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null);
    //Get all attachment posts
    $attachments = get_posts($args);
    //if there are posts
    if ($attachments) {
        $sit_settings = get_option('sit_settings');
        if ($sit_settings['enable_pdf']) {
            $pdf = true;
            $pdf_mine = 'pdf';
        }
        $image_mime = 'image';
        //Loop thru each attachment
        foreach ($attachments as $post) {
            //get post data ready,set title var to post title
            setup_postdata($post);
            $title = sanitize_text_field(get_the_title($post->ID));
            $type = get_post_mime_type($post->ID);
            $tag = sanitize_text_field(get_post_meta($post->ID, '_wp_attachment_image_alt', true));
            $tag_str = strval($tag);
            $tag_len = strlen($tag_str);
            //echo $type;
            if (strpos($type, $image_mime) !== false) {
                if ($is_update == True) {
                    //if has post meta for alt tag, update it else add it.
                    if (!add_post_meta($post->ID, '_wp_attachment_image_alt', $title, true)) {
                        if (empty($tag) || $tag_len <= 2 && $tag_str !== $title) {
                            update_post_meta($post->ID, '_wp_attachment_image_alt', $title);
                            $updated++;
                        }
                    } else {
                        $created++;
                        //update counter
                    }
                } else {
                    //if has post meta for alt tag, update it else add it.
                    if (!empty($tag)) {
                        delete_post_meta($post->ID, '_wp_attachment_image_alt', $title);
                        $deleted++;
                        //update counter
                    }
                    //end add_post_meta
                }
                $total++;
            }
        }
        //end foreach
    }
    //end attachments
    $count = array('total' => $total, 'created' => $created, 'updated' => $updated, 'deleted' => $deleted);
    //count of files updated
    return $count;
}
开发者ID:amgxyz,项目名称:seo-image-alt-tags,代码行数:58,代码来源:seo-image-alt-tags.php


示例18: getFeaturedImage

 public static function getFeaturedImage()
 {
     $media_att_id = get_post_thumbnail_id(get_the_ID());
     if ('image' == substr(get_post_mime_type($media_att_id), 0, 5)) {
         return wp_get_attachment_url($media_att_id);
     } else {
         return null;
     }
 }
开发者ID:gidbot,项目名称:treble_zero,代码行数:9,代码来源:class.Zero__Featured_Area.php


示例19: sp_generate_attachment_metadata

function sp_generate_attachment_metadata($attachment_id, $file)
{
    $attachment = get_post($attachment_id);
    $metadata = array();
    if (preg_match('!^image/!', get_post_mime_type($attachment)) && file_is_displayable_image($file)) {
        $imagesize = getimagesize($file);
        $metadata['width'] = $imagesize[0];
        $metadata['height'] = $imagesize[1];
        list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
        $metadata['hwstring_small'] = "height='{$uheight}' width='{$uwidth}'";
        // Make the file path relative to the upload dir
        $metadata['file'] = $attachment->post_title;
        // make thumbnails and other intermediate sizes
        global $_wp_additional_image_sizes;
        $temp_sizes = array('thumbnail', 'medium', 'large');
        // Standard sizes
        if (isset($_wp_additional_image_sizes) && count($_wp_additional_image_sizes)) {
            $temp_sizes = array_merge($temp_sizes, array_keys($_wp_additional_image_sizes));
        }
        $temp_sizes = apply_filters('intermediate_image_sizes', $temp_sizes);
        foreach ($temp_sizes as $s) {
            $sizes[$s] = array('width' => '', 'height' => '', 'crop' => FALSE);
            if (isset($_wp_additional_image_sizes[$s]['width'])) {
                $sizes[$s]['width'] = intval($_wp_additional_image_sizes[$s]['width']);
            } else {
                $sizes[$s]['width'] = get_option("{$s}_size_w");
            }
            // For default sizes set in options
            if (isset($_wp_additional_image_sizes[$s]['height'])) {
                $sizes[$s]['height'] = intval($_wp_additional_image_sizes[$s]['height']);
            } else {
                $sizes[$s]['height'] = get_option("{$s}_size_h");
            }
            // For default sizes set in options
            if (isset($_wp_additional_image_sizes[$s]['crop'])) {
                $sizes[$s]['crop'] = intval($_wp_additional_image_sizes[$s]['crop']);
            } else {
                $sizes[$s]['crop'] = get_option("{$s}_crop");
            }
            // For default sizes set in options
        }
        $sizes = apply_filters('intermediate_image_sizes_advanced', $sizes);
        foreach ($sizes as $size => $size_data) {
            $resized = image_make_intermediate_size($file, $size_data['width'], $size_data['height'], $size_data['crop']);
            if ($resized) {
                $metadata['sizes'][$size] = $resized;
            }
        }
        // fetch additional metadata from exif/iptc
        $image_meta = wp_read_image_metadata($file);
        if ($image_meta) {
            $metadata['image_meta'] = $image_meta;
        }
    }
    return apply_filters('wp_generate_attachment_metadata', $metadata, $attachment_id);
}
开发者ID:voodoobettie,项目名称:staypressproperty,代码行数:56,代码来源:functions.php


示例20: wpsc_select_product_file

/**
 * Returns HTML for Digital Download UI
 *
 * @param int $product_id
 * @return HTML
 */
function wpsc_select_product_file($product_id = null)
{
    global $wpdb;
    $product_id = absint($product_id);
    $file_list = wpsc_uploaded_files();
    $args = array('post_type' => 'wpsc-product-file', 'post_parent' => $product_id, 'numberposts' => -1, 'post_status' => 'all');
    $attached_files = (array) get_posts($args);
    $output = '<table id="wpsc_digital_download_table" class="wp-list-table widefat posts select_product_file">';
    $output .= '<thead>';
    $output .= '<tr>';
    $output .= '<th>' . _x('Title', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '<th>' . _x('Size', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '<th>' . _x('File Type', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '<th id="wpsc_digital_download_action_th">' . _x('Actions', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '</tr>';
    $output .= '</thead>';
    $output .= '<tfoot>';
    $output .= '<tr>';
    $output .= '<th>' . _x('Title', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '<th>' . _x('Size', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '<th>' . _x('File Type', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '<th id="wpsc_digital_download_action_th">' . _x('Actions', 'Digital download UI', 'wp-e-commerce') . '</th>';
    $output .= '</tr>';
    $output .= '</tfoot>';
    $num = 0;
    $output .= '<tbody>';
    $delete_nonce = _wpsc_create_ajax_nonce('delete_file');
    foreach ((array) $attached_files as $file) {
        $file_dir = WPSC_FILE_DIR . $file->post_title;
        $file_size = 'http://s3file' == $file->guid ? __('Remote file sizes cannot be calculated', 'wp-e-commerce') : wpsc_convert_byte(filesize($file_dir));
        $file_url = add_query_arg(array('wpsc_download_id' => $file->ID, '_wpnonce' => wp_create_nonce('wpsc-admin-download-file-' . $file->ID)), admin_url());
        $deletion_url = wp_nonce_url("admin.php?wpsc_admin_action=delete_file&amp;file_name={$file->post_title}&amp;product_id={$product_id}&amp;row_number={$num}", 'delete_file_' . $file->post_title);
        $class = !wpsc_is_odd($num) ? 'alternate' : '';
        $file_type = get_post_mime_type($file->ID);
        $icon_url = wp_mime_type_icon($file_type);
        $output .= '<tr class="wpsc_product_download_row ' . $class . '">';
        $output .= '<td style="padding-right: 30px;"><img src="' . $icon_url . '"><span>' . $file->post_title . '</span></td>';
        $output .= '<td>' . $file_size . '</td>';
        $output .= '<td>' . $file_type . '</td>';
        $output .= '<td><a href="' . esc_url($file_url) . '">' . _x('Download', 'Digital download row UI', 'wp-e-commerce') . '</a><a data-file-name="' . esc_attr($file->post_title) . '" data-product-id="' . esc_attr($product_id) . '" data-nonce="' . esc_attr($delete_nonce) . '" class="file_delete_button" href="' . $deletion_url . '" >' . _x("Delete", "Digital download row UI", 'wp-e-commerce') . '</a></td>';
        $output .= '</tr>';
        $num++;
    }
    $output .= '</tbody>';
    $output .= '</table>';
    if (empty($attached_files)) {
        $output .= "<p class='no-item'>" . __('There are no files attached to this product. Upload a new file or select from other product files.', 'wp-e-commerce') . "</p>";
    }
    $output .= "<div class='" . (is_numeric($product_id) ? 'edit_' : '') . "select_product_handle'></div>";
    $output .= "<script type='text/javascript'>\r\n";
    $output .= "var select_min_height = " . 25 * 3 . ";\r\n";
    $output .= "var select_max_height = " . 25 * ($num + 1) . ";\r\n";
    $output .= "</script>";
    return $output;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:61,代码来源:form-display.functions.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_post_mime_types函数代码示例发布时间:2022-05-15
下一篇:
PHP get_post_meta_by_id函数代码示例发布时间: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