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


PHP wp_mime_type_icon函数代码示例

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


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


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