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

PHP wp_mime_type_icon函数代码示例

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

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



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

示例1: 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


示例2: get_preview_from_url

 public static function get_preview_from_url($url)
 {
     $preview = '';
     $images = array('jpg', 'jpeg', 'bmp', 'gif', 'png');
     if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) {
         // check for extension, if it has extension then use it
         $info = pathinfo($url);
         if (isset($info['extension'])) {
             if (in_array($info['extension'], $images)) {
                 $preview = $url;
             } else {
                 $type = wp_ext2type($info['extension']);
                 if (is_null($type)) {
                     $type = 'default';
                 }
                 $preview = includes_url() . 'images/crystal/' . $type . '.png';
             }
         } else {
             // if no extension, try to discover from mime
             $mime = wp_remote_head($url);
             if (!is_wp_error($mime)) {
                 $mime = $mime['headers']['content-type'];
                 if (strpos($mime, 'image') === 0) {
                     $preview = $url;
                 } else {
                     $preview = wp_mime_type_icon($mime);
                 }
             } else {
                 $preview = includes_url() . 'images/crystal/' . 'default' . '.png';
             }
         }
     }
     return $preview;
 }
开发者ID:ntnvu,项目名称:tcb_online,代码行数:34,代码来源:res.php


示例3: attach_html

 public static function attach_html($attach_id, $type = NULL)
 {
     if (!$type) {
         $type = isset($_GET['type']) ? $_GET['type'] : 'image';
     }
     $attachment = get_post($attach_id);
     if (!$attachment) {
         return;
     }
     if (wp_attachment_is_image($attach_id)) {
         $image = wp_get_attachment_image_src($attach_id, 'thumbnail');
         $image = $image[0];
     } else {
         $image = wp_mime_type_icon($attach_id);
     }
     $html = '<li class="wpuf-image-wrap thumbnail">';
     $html .= sprintf('<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title));
     if (wpuf_get_option('image_caption', 'wpuf_general', 'off') == 'on') {
         $html .= '<div class="wpuf-file-input-wrap">';
         $html .= sprintf('<input type="text" name="wpuf_files_data[%d][title]" value="%s" placeholder="%s">', $attach_id, esc_attr($attachment->post_title), __('Title', 'wpuf'));
         $html .= sprintf('<textarea name="wpuf_files_data[%d][caption]" placeholder="%s">%s</textarea>', $attach_id, __('Caption', 'wpuf'), esc_textarea($attachment->post_excerpt));
         $html .= sprintf('<textarea name="wpuf_files_data[%d][desc]" placeholder="%s">%s</textarea>', $attach_id, __('Description', 'wpuf'), esc_textarea($attachment->post_content));
         $html .= '</div>';
     }
     $html .= sprintf('<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id);
     $html .= sprintf('<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __('Delete', 'wpuf'));
     $html .= '</li>';
     return $html;
 }
开发者ID:trdvelho,项目名称:estoque_wp,代码行数:29,代码来源:upload.php


示例4: acf_input_admin_l10n

 function acf_input_admin_l10n($l10n)
 {
     // append
     $l10n['media'] = array('select' => __("Select", 'acf'), 'edit' => __("Edit", 'acf'), 'update' => __("Update", 'acf'), 'uploadedTo' => __("Uploaded to this post", 'acf'), 'default_icon' => wp_mime_type_icon());
     // return
     return $l10n;
 }
开发者ID:cimocimocimo,项目名称:staydrysystems.com,代码行数:7,代码来源:media.php


示例5: aa_xml_mime_type_icon

function aa_xml_mime_type_icon($icon, $mime, $post_id)
{
    if ($mime == 'application/xml' || $mime == 'text/xml' || $mime == 'application/tei+xml') {
        return wp_mime_type_icon('document');
    }
    return $icon;
}
开发者ID:Nashev,项目名称:WordPress-TEI-XML,代码行数:7,代码来源:aa-tei-xml.php


示例6: to_json

 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @see WP_Fields_API_Control::to_json()
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['label'] = html_entity_decode($this->label, ENT_QUOTES, get_bloginfo('charset'));
     $this->json['mime_type'] = $this->mime_type;
     $this->json['button_labels'] = $this->button_labels;
     $this->json['canUpload'] = current_user_can('upload_files');
     $value = $this->value();
     if (is_object($this->setting)) {
         if ($this->setting->default) {
             // Fake an attachment model - needs all fields used by template.
             // Note that the default value must be a URL, NOT an attachment ID.
             $type = in_array(substr($this->setting->default, -3), array('jpg', 'png', 'gif', 'bmp')) ? 'image' : 'document';
             $default_attachment = array('id' => 1, 'url' => $this->setting->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->setting->default));
             if ('image' === $type) {
                 $default_attachment['sizes'] = array('full' => array('url' => $this->setting->default));
             }
             $this->json['defaultAttachment'] = $default_attachment;
         }
         if ($value && $this->setting->default && $value === $this->setting->default) {
             // Set the default as the attachment.
             $this->json['attachment'] = $this->json['defaultAttachment'];
         } elseif ($value) {
             $this->json['attachment'] = wp_prepare_attachment_for_js($value);
         }
     }
 }
开发者ID:Ramoonus,项目名称:wordpress-fields-api,代码行数:32,代码来源:class-wp-fields-api-media-control.php


示例7: file_gallery_get_file_type

/**
 * returns descriptive document type
 * used for icons in attachment list
 * both in backend and frontend
 *
 * needs more options and maybe a different approach...
 * @deprecated since 1.7.4
 */
function file_gallery_get_file_type($mime)
{
    return wp_mime_type_icon($mime);
    if (false !== strpos($mime, "text") || false !== strpos($mime, "xhtml")) {
        $type = "text";
    } elseif (false !== strpos($mime, "excel")) {
        $type = "spreadsheet";
    } elseif (false !== strpos($mime, "powerpoint")) {
        $type = "interactive";
    } elseif (false !== strpos($mime, "code")) {
        $type = "code";
    } elseif (false !== strpos($mime, "octet-stream")) {
        $type = "interactive";
    } elseif (false !== strpos($mime, "audio")) {
        $type = "audio";
    } elseif (false !== strpos($mime, "video")) {
        $type = "video";
    } elseif (false !== strpos($mime, "stuffit") || false !== strpos($mime, "compressed") || false !== strpos($mime, "x-tar") || false !== strpos($mime, "zip")) {
        $type = "archive";
    } elseif (false !== strpos($mime, "application")) {
        $type = "document";
    } else {
        $type = "default";
    }
    return apply_filters('file_gallery_get_file_type', $type, $mime);
}
开发者ID:kyme-online,项目名称:Ramesh-Photography,代码行数:34,代码来源:mime-types.php


示例8: json

 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @see WP_Fields_API_Control::to_json()
  */
 public function json()
 {
     $json = parent::json();
     $json['mime_type'] = $this->mime_type;
     $json['button_labels'] = $this->button_labels;
     $json['canUpload'] = current_user_can('upload_files');
     $value = $this->value();
     if (is_object($this->field)) {
         if ($this->field->default) {
             // Fake an attachment model - needs all fields used by template.
             // Note that the default value must be a URL, NOT an attachment ID.
             $type = 'document';
             if (in_array(substr($this->field->default, -3), array('jpg', 'png', 'gif', 'bmp'))) {
                 $type = 'image';
             }
             $default_attachment = array('id' => 1, 'url' => $this->field->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->field->default));
             if ('image' === $type) {
                 $default_attachment['sizes'] = array('full' => array('url' => $this->field->default));
             }
             $json['defaultAttachment'] = $default_attachment;
         }
         if ($value && $this->field->default && $value === $this->field->default) {
             // Set the default as the attachment.
             $json['attachment'] = $json['defaultAttachment'];
         } elseif ($value) {
             $json['attachment'] = wp_prepare_attachment_for_js($value);
         }
     }
     return $json;
 }
开发者ID:machouinard,项目名称:wordpress-fields-api,代码行数:35,代码来源:class-wp-fields-api-media-control.php


示例9: widget

 /**
  * Outputs the content of the widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     // outputs the content of the widget
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     $number_of_posts = -1;
     if (!empty($instance['show_number_files'])) {
         $number_of_posts = $instance['show_number_files'];
     }
     $orderby = 'date';
     if (!empty($instance['sort_parameter'])) {
         $orderby = $instance['sort_parameter'];
     }
     $order_direction = 'DESC';
     if (!empty($instance['sort_direction'])) {
         $order_direction = $instance['sort_direction'];
     }
     $exclude_ids = array();
     if (!empty($instance['exclude_ids'])) {
         $exclude_ids = $instance['exclude_ids'];
     }
     // TODO: get template choice. Echo css based on choice
     echo '<style>.list_mediafiles_box{';
     echo 'border: 1px solid #e2e2e2;';
     echo 'margin: 5px;';
     echo 'padding: 5px;';
     echo '} .list_mediafiles_box img{';
     echo 'max-width:100px;';
     echo '} </style>';
     $args = array('post_type' => 'attachment', 'numberposts' => $number_of_posts, 'post_status' => null, 'post_parent' => null, 'orderby' => $orderby, 'order' => $order_direction, 'exclude' => $exclude_ids);
     $attachments = get_posts($args);
     if ($attachments) {
         foreach ($attachments as $post) {
             echo '<div class="list_mediafiles_box">';
             setup_postdata($post);
             echo '<h4>' . get_the_title($post->ID) . '</h4>';
             switch ($post->post_mime_type) {
                 case 'image/jpeg':
                 case 'image/png':
                 case 'image/gif':
                     the_attachment_link($post->ID, false);
                     break;
                 default:
                     echo '<a href="' . get_attachment_link($post->ID) . '"><img src="' . wp_mime_type_icon($post->post_mime_type) . '"></a>';
             }
             echo '<span class="aligncenter" style="word-break:break-word;">';
             the_excerpt();
             echo '</span>';
             echo '</div>';
         }
     }
     //echo $args['after_widget'];
 }
开发者ID:klasske,项目名称:wp_list_mediafiles_widget,代码行数:61,代码来源:list_mediafiles.php


示例10: 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


示例11: getThumbnail

 /**
  * Get thumbnail URL for document with given ID from default images.
  *
  * @param string $ID The attachment ID to retrieve thumbnail from.
  * @param int $pg Unused.
  *
  * @return string     URL to thumbnail.
  */
 public function getThumbnail($ID, $pg = 1)
 {
     static $image_exts = array('jpg', 'jpeg', 'gif', 'png');
     $icon_url = DG_URL . 'assets/icons/';
     $ext = self::getExt(wp_get_attachment_url($ID));
     // handle images
     if (in_array($ext, $image_exts) && ($icon = self::getImageThumbnail($ID))) {
         // Nothing to do
     } elseif ($name = self::getDefaultIcon($ext)) {
         // try DG custom default icons first
         $icon = $icon_url . $name;
         // then fall back to standard WP default icons
     } elseif (!($icon = wp_mime_type_icon($ID))) {
         // everything failed. This is bad...
         $icon = $icon_url . 'missing.png';
     }
     return $icon;
 }
开发者ID:WildCodeSchool,项目名称:projet-maison_ados_dreux,代码行数:26,代码来源:class-default-thumber.php


示例12: attach_html

 public static function attach_html($attach_id, $custom_attr = [])
 {
     $attachment = get_post($attach_id);
     if (!$attachment) {
         return;
     }
     if (wp_attachment_is_image($attach_id)) {
         $image = wp_get_attachment_image_src($attach_id, array('80', '80'));
         $image = $image[0];
     } else {
         $image = wp_mime_type_icon($attach_id);
     }
     $html = '<li class="erp-image-wrap thumbnail">';
     $html .= sprintf('<div class="attachment-name"><img class="erp-file-mime" ' . implode(' data-', $custom_attr) . ' height="80" width="80" src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title));
     $html .= sprintf('<input type="hidden" name="files[]" value="%d">', $attach_id);
     $html .= sprintf('<div class="caption"><a href="#" class="erp-del-attc-button btn-danger btn-small attachment-delete" data-attach_id="%d">X</a></div>', $attach_id);
     $html .= '</li>';
     return $html;
 }
开发者ID:ediamin,项目名称:wp-erp,代码行数:19,代码来源:class-uploader.php


示例13: attach_html

 public static function attach_html($attach_id, $type = NULL)
 {
     if (!$type) {
         $type = isset($_GET['type']) ? $_GET['type'] : 'image';
     }
     $attachment = get_post($attach_id);
     if (!$attachment) {
         return;
     }
     if (wp_attachment_is_image($attach_id)) {
         $image = wp_get_attachment_image_src($attach_id, 'thumbnail');
         $image = $image[0];
     } else {
         $image = wp_mime_type_icon($attach_id);
     }
     $html = '<li class="image-wrap thumbnail" style="width: 150px">';
     $html .= sprintf('<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title));
     $html .= sprintf('<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __('Delete', 'wpuf'));
     $html .= sprintf('<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id);
     $html .= '</li>';
     return $html;
 }
开发者ID:brunolampada,项目名称:foss4g2014-wordpress,代码行数:22,代码来源:upload.php


示例14: to_json

 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  *
  * highly based on WP_Customize_Media_Control merged with WP_Customize_Upload_Control ::to_json()
  */
 public function to_json()
 {
     $this->json['mime_type'] = $this->mime_type;
     $this->json['button_labels'] = $this->button_labels;
     $this->json['bg_repeat_options'] = $this->bg_repeat_options;
     $this->json['bg_attachment_options'] = $this->bg_attachment_options;
     $this->json['bg_position_options'] = $this->bg_position_options;
     $this->json['canUpload'] = current_user_can('upload_files');
     $this->json['default_model'] = $this->default_model;
     $value = $this->value();
     if (isset($this->setting) && is_object($this->setting)) {
         $_defaults = isset($this->setting->default) ? $this->setting->default : null;
         $default_bg_img = isset($_defaults['background-image']) ? $_defaults['background-image'] : null;
     }
     $default_bg_im = isset($default_bg_img) ? $default_bg_img : null;
     if ($default_bg_img) {
         // Fake an attachment model - needs all fields used by template.
         // Note that the default value must be a URL, NOT an attachment ID.
         $type = in_array(substr($default_bg_img, -3), array('jpg', 'png', 'gif', 'bmp', 'svg')) ? 'image' : 'document';
         $default_attachment = array('id' => 1, 'url' => $default_bg_img, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($default_bg_img));
         $default_attachment['sizes'] = array('full' => array('url' => $default_bg_img));
         $this->json['defaultAttachment'] = $default_attachment;
     }
     $background_image = isset($value['background-image']) ? $value['background-image'] : null;
     if ($background_image && $default_bg_img && $background_image === $default_bg_img) {
         // Set the default as the attachment.
         $this->json['attachment'] = $this->json['defaultAttachment'];
     } elseif ($background_image) {
         $attachment_id = attachment_url_to_postid($background_image);
         if ($attachment_id) {
             $this->json['attachment'] = wp_prepare_attachment_for_js($attachment_id);
         } else {
             //already an id
             $this->json['attachment'] = wp_prepare_attachment_for_js($background_image);
         }
     }
     parent::to_json();
 }
开发者ID:giorgioriccardi,项目名称:hueman,代码行数:44,代码来源:class-background-control.php


示例15: xt_manage_post_custom_column

function xt_manage_post_custom_column($column, $post_id)
{
    switch ($column) {
        case 'icon':
            $att_title = _draft_or_post_title();
            ?>
				<a href="<?php 
            echo esc_url(get_edit_post_link($post_id, true));
            ?>
" title="<?php 
            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', XT_TEXT_DOMAIN), $att_title));
            ?>
"><?php 
            if ($thumb = get_the_post_thumbnail($post_id, array(80, 60))) {
                echo $thumb;
            } else {
                echo '<img width="46" height="60" src="' . wp_mime_type_icon('image/jpeg') . '" alt="">';
            }
            ?>
</a>
<?php 
            break;
    }
}
开发者ID:venturepact,项目名称:blog,代码行数:24,代码来源:setup-news.php


示例16: render_field

        function render_field($field)
        {
            // enqueue
            acf_enqueue_uploader();
            // vars
            $posts = array();
            $atts = array('id' => $field['id'], 'class' => "acf-gallery {$field['class']}", 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library'], 'data-min' => $field['min'], 'data-max' => $field['max'], 'data-mime_types' => $field['mime_types']);
            // set gallery height
            $height = acf_get_user_setting('gallery_height', 400);
            $height = max($height, 200);
            // minimum height is 200
            $atts['style'] = "height:{$height}px";
            // load posts
            if (!empty($field['value'])) {
                $posts = acf_get_posts(array('post_type' => 'attachment', 'post__in' => $field['value']));
            }
            ?>
<div <?php 
            acf_esc_attr_e($atts);
            ?>
>
	
	<div class="acf-hidden">
		<input type="hidden" <?php 
            acf_esc_attr_e(array('name' => $field['name'], 'value' => '', 'data-name' => 'ids'));
            ?>
 />
	</div>
	
	<div class="acf-gallery-main">
		
		<div class="acf-gallery-attachments">
			
			<?php 
            if (!empty($posts)) {
                ?>
			
				<?php 
                foreach ($posts as $post) {
                    // vars
                    $type = acf_maybe_get(explode('/', $post->post_mime_type), 0);
                    $thumb_id = $post->ID;
                    $thumb_url = '';
                    $thumb_class = 'acf-gallery-attachment acf-soh';
                    $filename = wp_basename($post->guid);
                    // thumb
                    if ($type === 'image' || $type === 'audio' || $type === 'video') {
                        // change $thumb_id
                        if ($type === 'audio' || $type === 'video') {
                            $thumb_id = get_post_thumbnail_id($post->ID);
                        }
                        // get attachment
                        if ($thumb_id) {
                            $thumb_url = wp_get_attachment_image_src($thumb_id, $field['preview_size']);
                            $thumb_url = acf_maybe_get($thumb_url, 0);
                        }
                    }
                    // fallback
                    if (!$thumb_url) {
                        $thumb_url = wp_mime_type_icon($post->ID);
                        $thumb_class .= ' is-mime-icon';
                    }
                    ?>
					<div class="<?php 
                    echo $thumb_class;
                    ?>
" data-id="<?php 
                    echo $post->ID;
                    ?>
">
						<input type="hidden" name="<?php 
                    echo $field['name'];
                    ?>
[]" value="<?php 
                    echo $post->ID;
                    ?>
" />
						<div class="margin" title="<?php 
                    echo $filename;
                    ?>
">
							<div class="thumbnail">
								<img src="<?php 
                    echo $thumb_url;
                    ?>
"/>
							</div>
							<?php 
                    if ($type !== 'image') {
                        ?>
							<div class="filename"><?php 
                        echo acf_get_truncated($filename, 18);
                        ?>
</div>
							<?php 
                    }
                    ?>
						</div>
						<div class="actions acf-soh-target">
							<a class="acf-icon dark remove-attachment" data-id="<?php 
//.........这里部分代码省略.........
开发者ID:TMBR,项目名称:johnjohn,代码行数:101,代码来源:gallery.php


示例17: wp_prepare_attachment_for_js

/**
 * Prepares an attachment post object for JS, where it is expected
 * to be JSON-encoded and fit into an Attachment model.
 *
 * @since 3.5.0
 *
 * @param mixed $attachment Attachment ID or object.
 * @return array|void Array of attachment details.
 */
function wp_prepare_attachment_for_js($attachment)
{
    if (!($attachment = get_post($attachment))) {
        return;
    }
    if ('attachment' != $attachment->post_type) {
        return;
    }
    $meta = wp_get_attachment_metadata($attachment->ID);
    if (false !== strpos($attachment->post_mime_type, '/')) {
        list($type, $subtype) = explode('/', $attachment->post_mime_type);
    } else {
        list($type, $subtype) = array($attachment->post_mime_type, '');
    }
    $attachment_url = wp_get_attachment_url($attachment->ID);
    $response = array('id' => $attachment->ID, 'title' => $attachment->post_title, 'filename' => wp_basename(get_attached_file($attachment->ID)), 'url' => $attachment_url, 'link' => get_attachment_link($attachment->ID), 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true), 'author' => $attachment->post_author, 'description' => $attachment->post_content, 'caption' => $attachment->post_excerpt, 'name' => $attachment->post_name, 'status' => $attachment->post_status, 'uploadedTo' => $attachment->post_parent, 'date' => strtotime($attachment->post_date_gmt) * 1000, 'modified' => strtotime($attachment->post_modified_gmt) * 1000, 'menuOrder' => $attachment->menu_order, 'mime' => $attachment->post_mime_type, 'type' => $type, 'subtype' => $subtype, 'icon' => wp_mime_type_icon($attachment->ID), 'dateFormatted' => mysql2date(get_option('date_format'), $attachment->post_date), 'nonces' => array('update' => false, 'delete' => false, 'edit' => false), 'editLink' => false, 'meta' => false);
    $author = new WP_User($attachment->post_author);
    $response['authorName'] = $author->display_name;
    if ($attachment->post_parent) {
        $post_parent = get_post($attachment->post_parent);
    } else {
        $post_parent = false;
    }
    if ($post_parent) {
        $parent_type = get_post_type_object($post_parent->post_type);
        if ($parent_type && $parent_type->show_ui && current_user_can('edit_post', $attachment->post_parent)) {
            $response['uploadedToLink'] = get_edit_post_link($attachment->post_parent, 'raw');
        }
        $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __('(no title)');
    }
    $attached_file = get_attached_file($attachment->ID);
    if (isset($meta['filesize'])) {
        $bytes = $meta['filesize'];
    } elseif (file_exists($attached_file)) {
        $bytes = filesize($attached_file);
    } else {
        $bytes = '';
    }
    if ($bytes) {
        $response['filesizeInBytes'] = $bytes;
        $response['filesizeHumanReadable'] = size_format($bytes);
    }
    if (current_user_can('edit_post', $attachment->ID)) {
        $response['nonces']['update'] = wp_create_nonce('update-post_' . $attachment->ID);
        $response['nonces']['edit'] = wp_create_nonce('image_editor-' . $attachment->ID);
        $response['editLink'] = get_edit_post_link($attachment->ID, 'raw');
    }
    if (current_user_can('delete_post', $attachment->ID)) {
        $response['nonces']['delete'] = wp_create_nonce('delete-post_' . $attachment->ID);
    }
    if ($meta && 'image' === $type) {
        $sizes = array();
        /** This filter is documented in wp-admin/includes/media.php */
        $possible_sizes = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
        unset($possible_sizes['full']);
        // Loop through all potential sizes that may be chosen. Try to do this with some efficiency.
        // First: run the image_downsize filter. If it returns something, we can use its data.
        // If the filter does not return something, then image_downsize() is just an expensive
        // way to check the image metadata, which we do second.
        foreach ($possible_sizes as $size => $label) {
            /** This filter is documented in wp-includes/media.php */
            if ($downsize = apply_filters('image_downsize', false, $attachment->ID, $size)) {
                if (!$downsize[3]) {
                    continue;
                }
                $sizes[$size] = array('height' => $downsize[2], 'width' => $downsize[1], 'url' => $downsize[0], 'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape');
            } elseif (isset($meta['sizes'][$size])) {
                if (!isset($base_url)) {
                    $base_url = str_replace(wp_basename($attachment_url), '', $attachment_url);
                }
                // Nothing from the filter, so consult image metadata if we have it.
                $size_meta = $meta['sizes'][$size];
                // We have the actual image size, but might need to further constrain it if content_width is narrower.
                // Thumbnail, medium, and full sizes are also checked against the site's height/width options.
                list($width, $height) = image_constrain_size_for_editor($size_meta['width'], $size_meta['height'], $size, 'edit');
                $sizes[$size] = array('height' => $height, 'width' => $width, 'url' => $base_url . $size_meta['file'], 'orientation' => $height > $width ? 'portrait' : 'landscape');
            }
        }
        $sizes['full'] = array('url' => $attachment_url);
        if (isset($meta['height'], $meta['width'])) {
            $sizes['full']['height'] = $meta['height'];
            $sizes['full']['width'] = $meta['width'];
            $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape';
        }
        $response = array_merge($response, array('sizes' => $sizes), $sizes['full']);
    } elseif ($meta && 'video' === $type) {
        if (isset($meta['width'])) {
            $response['width'] = (int) $meta['width'];
        }
        if (isset($meta['height'])) {
            $response['height'] = (int) $meta['height'];
//.........这里部分代码省略.........
开发者ID:nakamuraagatha,项目名称:reseptest,代码行数:101,代码来源:media.php


示例18: test_wp_mime_type_icon_video

 /**
  * @ticket 33012
  */
 public function test_wp_mime_type_icon_video()
 {
     $icon = wp_mime_type_icon('video/mp4');
     $this->assertContains('images/media/video.png', $icon);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:8,代码来源:attachments.php


示例19: wp_playlist_shortcode

    function wp_playlist_shortcode($output, $attr)
    {
        global $content_width;
        $post = get_post();
        static $instance = 0;
        $instance++;
        if (isset($attr['orderby'])) {
            $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
            if (!$attr['orderby']) {
                unset($attr['orderby']);
            }
        }
        extract(shortcode_atts(array('type' => 'audio', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'include' => '', 'exclude' => '', 'style' => 'light', 'tracklist' => true, 'tracknumbers' => true, 'images' => true, 'artists' => true), $attr, 'playlist'));
        $id = intval($id);
        if ('RAND' == $order) {
            $orderby = 'none';
        }
        $args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => $type, 'order' => $order, 'orderby' => $orderby);
        if (!empty($include)) {
            $args['include'] = $include;
            $_attachments = get_posts($args);
            $attachments = array();
            foreach ($_attachments as $key => $val) {
                $attachments[$val->ID] = $_attachments[$key];
            }
        } elseif (!empty($exclude)) {
            $args['post_parent'] = $id;
            $args['exclude'] = $exclude;
            $attachments = get_children($args);
        } else {
            $args['post_parent'] = $id;
            $attachments = get_children($args);
        }
        if (empty($attachments)) {
            return '';
        }
        if (is_feed()) {
            $output = "\n";
            foreach ($attachments as $att_id => $attachment) {
                $output .= wp_get_attachment_link($att_id) . "\n";
            }
            return $output;
        }
        $outer = 22;
        $default_width = 640;
        $default_height = 360;
        $theme_width = empty($content_width) ? $default_width : $content_width - $outer;
        $theme_height = empty($content_width) ? $default_height : round($default_height * $theme_width / $default_width);
        $data = compact('type');
        foreach (array('tracklist', 'tracknumbers', 'images', 'artists') as $key) {
            $data[$key] = filter_var(${$key}, FILTER_VALIDATE_BOOLEAN);
        }
        $tracks = array();
        foreach ($attachments as $attachment) {
            $url = wp_get_attachment_url($attachment->ID);
            $ftype = wp_check_filetype($url, wp_get_mime_types());
            $track = array('src' => $url, 'type' => $ftype['type'], 'title' => $attachment->post_title, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content);
            $track['meta'] = array();
            $meta = wp_get_attachment_metadata($attachment->ID);
            if (!empty($meta)) {
                foreach (wp_get_attachment_id3_keys($attachment) as $key => $label) {
                    if (!empty($meta[$key])) {
                        $track['meta'][$key] = $meta[$key];
                    }
                }
                if ('video' === $type) {
                    if (!empty($meta['width']) && !empty($meta['height'])) {
                        $width = $meta['width'];
                        $height = $meta['height'];
                        $theme_height = round($height * $theme_width / $width);
                    } else {
                        $width = $default_width;
                        $height = $default_height;
                    }
                    $track['dimensions'] = array('original' => compact('width', 'height'), 'resized' => array('width' => $theme_width, 'height' => $theme_height));
                }
            }
            if ($images) {
                $id = get_post_thumbnail_id($attachment->ID);
                if (!empty($id)) {
                    list($src, $width, $height) = wp_get_attachment_image_src($id, 'full');
                    $track['image'] = compact('src', 'width', 'height');
                    list($src, $width, $height) = wp_get_attachment_image_src($id, 'thumbnail');
                    $track['thumb'] = compact('src', 'width', 'height'); 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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