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

PHP wp_ext2type函数代码示例

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

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



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

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


示例2: get_attachment_type

 /**
  * Return the file type for an attachment which corresponds with a context label
  *
  * @param object $file_uri URI of the attachment
  *
  * @return string A file type which corresponds with a context label
  */
 public function get_attachment_type($file_uri)
 {
     $extension = pathinfo($file_uri, PATHINFO_EXTENSION);
     $extension_type = wp_ext2type($extension);
     if (empty($extension_type)) {
         $extension_type = 'document';
     }
     $context_labels = $this->get_context_labels();
     if (!isset($context_labels[$extension_type])) {
         $extension_type = 'document';
     }
     return $extension_type;
 }
开发者ID:selectSIFISO,项目名称:.comsite,代码行数:20,代码来源:class-connector-media.php


示例3: eshop_downloads

    function eshop_downloads($_POST, $images, $content)
    {
        global $wpdb, $eshopoptions;
        //cache
        eshop_cache();
        $table = $wpdb->prefix . "eshop_downloads";
        $ordertable = $wpdb->prefix . "eshop_download_orders";
        $dir_upload = eshop_download_directory();
        $echo = '';
        //download is handled via cart functions as it needs to
        //be accessible before anything is printed on the page
        if (isset($_POST['code']) && isset($_POST['email'])) {
            /*
            Need to add in check about number of downloads here, including unlimited!
            */
            $code = $wpdb->escape($_POST['code']);
            $email = $wpdb->escape($_POST['email']);
            $dlcount = $wpdb->get_var("SELECT COUNT(id) FROM {$ordertable} where email='{$email}' && code='{$code}' && downloads!='0'");
            if ($dlcount > 0) {
                $echo .= $content;
                $tsize = 0;
                $x = 0;
                if ($dlcount > 1 && $eshopoptions['downloads_hideall'] != 'yes') {
                    $echo .= '<p class="jdl"><a href="#dlall">' . __('Download all files', 'eshop') . '</a></p>';
                }
                $dlresult = $wpdb->get_results("Select * from {$ordertable} where email='{$email}' && code='{$code}' && downloads!='0'");
                foreach ($dlresult as $dlrow) {
                    //download single items.
                    $filepath = $dir_upload . $dlrow->files;
                    $dlfilesize = eshop_filesize($dlrow->files);
                    $tsize = $tsize + $dlfilesize;
                    if ($dlrow->downloads == 1) {
                        $dlword = __('download', 'eshop');
                    } else {
                        $dlword = __('downloads', 'eshop');
                    }
                    $imagetoadd = '';
                    if ($images == 'add') {
                        $checkit = wp_check_filetype($filepath);
                        $eshopext = wp_ext2type($checkit['ext']);
                        $eshopfiletypeimgurl = wp_mime_type_icon($eshopext);
                        $eshophead = wp_remote_head($eshopfiletypeimgurl);
                        $eshophresult = wp_remote_retrieve_response_code($eshophead);
                        if ($eshophresult == '200' || $eshophresult == '302') {
                            $dims = getimagesize($eshopfiletypeimgurl);
                        }
                        if (is_array($dims)) {
                            $dimensions = $dims[3];
                        } else {
                            $dimensions = '';
                        }
                        $imagetoadd = apply_filters('eshop_download_imgs', '<img class="eshop-download-icon" src="' . $eshopfiletypeimgurl . '" ' . $dimensions . ' alt="" />', $checkit['ext']);
                    }
                    $dltitle = strlen($dlrow->title) >= 20 ? substr($dlrow->title, 0, 20) . "&#8230;" : $dlrow->title;
                    $echo .= '
					<form method="post" action="" class="eshop dlproduct"><fieldset>
					<legend>' . $dltitle . ' (' . check_filesize($dlfilesize) . ')</legend>
					' . $imagetoadd . '
					<input name="email" type="hidden" value="' . $_POST['email'] . '" />
					<input name="code" type="hidden" value="' . $_POST['code'] . '" />
					<input name="id" type="hidden" value="' . $dlrow->id . '" />
					<input name="eshoplongdownloadname" type="hidden" value="yes" />
					<label for="ro' . $x . '">' . __('Number of downloads remaining', 'eshop') . '</label>
					<input type="text" readonly="readonly" name="ro" class="ro" id="ro' . $x . '" value="' . $dlrow->downloads . '" />
					<span class="buttonwrap"><input type="submit" class="button" id="submit' . $x . '" name="Submit" value="' . __('Download', 'eshop') . ' ' . $dltitle . '" /></span>
					</fieldset></form>';
                    $x++;
                    $size = 0;
                }
                if ($dlcount > 1 && $eshopoptions['downloads_hideall'] != 'yes') {
                    //download all form.
                    $echo .= '
					<form method="post" action="" id="dlall" class="eshop"><fieldset>
					<legend>' . __('Download all files', 'eshop') . ' (' . check_filesize($tsize) . ') ' . __('in one zip file.', 'eshop') . '</legend>
					<input name="email" type="hidden" value="' . $_POST['email'] . '" />
					<input name="code" type="hidden" value="' . $_POST['code'] . '" />
					<input name="id" type="hidden" value="all" />
					<input name="eshoplongdownloadname" type="hidden" value="yes" />
					<p><span class="buttonwrap"><input class="button" type="submit" id="submit" name="Submit" value="' . __('Download All Files', 'eshop') . '" /></span></p>
					</fieldset></form>
					';
                }
                //allow plugin to change output, validated email/passcode already
                $echo = apply_filters('eshop_download_page', $echo, $code, $email);
            } else {
                $prevdlcount = $wpdb->get_var("SELECT COUNT(id) FROM {$ordertable} where email='{$email}' && code='{$code}'");
                if ($dlcount == $prevdlcount) {
                    $error = '<p class="eshoperror error">' . __('Either your email address or code is incorrect, please try again.', 'eshop') . '</p>';
                } else {
                    $error = '<p class="eshoperror error">' . __('Your email address and code are correct, however you have no downloads remaining.', 'eshop') . '</p>';
                }
                $echo .= eshop_dloadform($email, $code, $error);
            }
        } else {
            $echo .= eshop_dloadform('', '');
        }
        return $echo;
    }
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:98,代码来源:purchase-downloads.php


示例4: test_wp_ext2type

 /**
  * @ticket 35987
  */
 public function test_wp_ext2type()
 {
     $extensions = wp_get_ext_types();
     foreach ($extensions as $type => $extensionList) {
         foreach ($extensionList as $extension) {
             $this->assertEquals($type, wp_ext2type($extension));
             $this->assertEquals($type, wp_ext2type(strtoupper($extension)));
         }
     }
     $this->assertNull(wp_ext2type('unknown_format'));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:14,代码来源:functions.php


示例5: gm_get_media_image

 /**
  * Get an HTML img element representing an image attachment
  * @see  add_image_size()
  * @see  wp_get_attachment_image()
  * @uses apply_filters() Calls 'gm_get_attachment_image_attributes' hook on attributes array
  *
  * @param int|object  $item    Image object.
  * @param string      $size    Optional, default is empty string, could be 'thumb', 'web', 'original'
  * @param bool        $cover   Optional, try to get cover url
  * @param bool|string $default Optional, return if no cover and if $size != 'all'
  *
  * @return string|array img url for chosen size
  */
 function gm_get_media_image($item, $size = '', $cover = true, $default = false)
 {
     global $gmDB, $gmGallery;
     if (!is_object($item)) {
         $item = $gmDB->get_gmedia($item);
     }
     if (!$size) {
         $size = 'web';
     }
     if (empty($item)) {
         $image = $default ? $default : $this->gmedia_url . '/admin/assets/img/blank.gif';
         $images = apply_filters('gm_get_media_image', array('thumb' => $image, 'web' => $image, 'original' => $image));
         if ('all' == $size) {
             return $images;
         } else {
             return $images[$size];
         }
     }
     $type = explode('/', $item->mime_type);
     if ('image' == $type[0]) {
         $images = array('thumb' => "{$this->upload['url']}/{$gmGallery->options['folder']['image_thumb']}/{$item->gmuid}", 'web' => "{$this->upload['url']}/{$gmGallery->options['folder']['image']}/{$item->gmuid}", 'original' => "{$this->upload['url']}/{$gmGallery->options['folder']['image_original']}/{$item->gmuid}");
         if ('all' == $size || 'original' == $size) {
             $original_path = "{$this->upload['path']}/{$gmGallery->options['folder']['image_original']}/{$item->gmuid}";
             if (!is_file($original_path)) {
                 $images['original'] = $images['web'];
             }
         }
     } else {
         $ext = ltrim(strrchr($item->gmuid, '.'), '.');
         if (!($type = wp_ext2type($ext))) {
             $type = 'application';
         }
         $image = "{$this->gmedia_url}/admin/assets/img/{$type}.png";
         $images = array('thumb' => $image, 'web' => $image, 'original' => $image);
         if ($cover) {
             $cover = $gmDB->get_metadata('gmedia', $item->ID, '_cover', true);
             if (!empty($cover)) {
                 if ($this->is_digit($cover)) {
                     $images = $this->gm_get_media_image((int) $cover, 'all', false);
                 }
             } elseif ($default !== false && $size !== 'all') {
                 return $default;
             }
         }
     }
     if ('all' == $size) {
         return $images;
     } else {
         return $images[$size];
     }
 }
开发者ID:pasyuk,项目名称:grand-media,代码行数:64,代码来源:core.php


示例6: GetType

 function GetType()
 {
     $ext = substr($this->GetExtension(), 1);
     if ($type = wp_ext2type($ext)) {
         return $type;
     }
     return $ext;
 }
开发者ID:TishoTM,项目名称:WP-Filebase,代码行数:8,代码来源:File.php


示例7: suffusion_get_audio_from_embedded_url

/**
 * Finds an audio file in a post by looking for the first embedded <a> tags. This can be used to pull external audio files from the post,
 * though it would work even for internal files.
 *
 * @return string
 */
function suffusion_get_audio_from_embedded_url()
{
    global $post;
    $audios = array();
    preg_match_all('|<a.*?href=[\'"](.*?)[\'"].*?>|i', $post->post_content, $links);
    if (isset($links) && isset($links[1]) && is_array($links[1])) {
        foreach ($links[1] as $link) {
            $dot_pos = strrpos($link, '.');
            if ($dot_pos < strlen($link)) {
                $extension = substr($link, $dot_pos + 1);
                if (wp_ext2type($extension) == 'audio') {
                    $audios[] = $link;
                }
            }
        }
    }
    return $audios;
}
开发者ID:kevinaxu,项目名称:99boulders,代码行数:24,代码来源:media.php


示例8: mla_add_upload_mime

 /**
  * Add an MLA Upload MIME Type object
  *
  * @since 1.40
  *
  * @param	array	Query variables for a single object, including slug
  *
  * @return	array	Message(s) reflecting the results of the operation
  */
 public static function mla_add_upload_mime($request)
 {
     if (self::_get_upload_mime_templates()) {
         $errors = '';
     } else {
         return array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Cannot load Upload MIME Types', 'media-library-assistant'), 'body' => '');
     }
     $messages = '';
     /*
      * Sanitize slug value
      */
     if (empty($request['slug'])) {
         $errors .= '<br>' . __('ERROR', 'media-library-assistant') . ': ' . __('Extension is required', 'media-library-assistant');
     } else {
         $slug = pathinfo('X.' . strtolower(trim($request['slug'])), PATHINFO_EXTENSION);
         if ($slug != $request['slug']) {
             /* translators: 1: element name 2: bad_value 3: good_value */
             $messages .= sprintf(__('<br>' . 'Changing %1$s "%2$s" to valid value "%3$s"', 'media-library-assistant'), __('Extension', 'media-library-assistant'), $request['slug'], $slug);
         }
         /*
          * Make sure new slug is unique
          */
         if (isset(self::$mla_upload_mime_templates[$slug])) {
             /* translators: 1: ERROR tag 2: slug */
             $errors .= '<br>' . sprintf(__('%1$s: Could not add extension "%2$s"; value already exists', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $slug);
         }
     }
     /*
      * Validate mime_type
      */
     if (empty($request['mime_type'])) {
         $errors .= '<br>' . __('ERROR', 'media-library-assistant') . ': ' . __('MIME type is required', 'media-library-assistant');
     } else {
         $clean_mime_type = sanitize_mime_type($request['mime_type']);
         if ($clean_mime_type != $request['mime_type']) {
             /* translators: 1: ERROR tag 2: clean_mime_type */
             $errors .= '<br>' . sprintf(__('%1$s: Bad MIME type; try "%2$s"', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $clean_mime_type);
         }
     }
     if (!empty($errors)) {
         return array('message' => substr($errors . $messages, 4), 'body' => '');
     }
     if ('.none.' == $request['icon_type']) {
         if (NULL == ($icon_type = wp_ext2type($slug))) {
             $icon_type = 'default';
         }
     } else {
         $icon_type = $request['icon_type'];
     }
     $new_type = array();
     $new_type['post_ID'] = ++self::$mla_upload_mime_highest_ID;
     $new_type['mime_type'] = $clean_mime_type;
     $new_type['core_type'] = '';
     $new_type['mla_type'] = '';
     $new_type['source'] = 'custom';
     $new_type['standard_source'] = '';
     $new_type['disabled'] = isset($request['disabled']) ? $request['disabled'] : false;
     $new_type['description'] = isset($request['description']) ? sanitize_text_field($request['description']) : '';
     $new_type['icon_type'] = $icon_type;
     $new_type['wp_icon_type'] = $icon_type;
     $new_type['mla_icon_type'] = $icon_type;
     $new_type['core_icon_type'] = self::mla_get_core_icon_type($slug);
     self::$mla_upload_mime_templates[$slug] = $new_type;
     if (self::_put_upload_mime_templates()) {
         return array('message' => substr($messages . '<br>' . sprintf(__('Upload MIME Type "%1$s"; added', 'media-library-assistant'), $slug), 4), 'body' => '');
     }
     return array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Cannot update Upload MIME Types', 'media-library-assistant'), 'body' => '');
 }
开发者ID:n3ssi3,项目名称:tauch-terminal,代码行数:77,代码来源:class-mla-mime-types.php


示例9: test_bp_attachments_get_allowed_types

 /**
  * @group bp_attachments
  */
 public function test_bp_attachments_get_allowed_types()
 {
     $supported = array('jpeg', 'gif', 'png');
     $avatar = bp_attachments_get_allowed_types('avatar');
     $this->assertSame($supported, $avatar);
     $cover_image = bp_attachments_get_allowed_types('cover_image');
     $this->assertSame($supported, $cover_image);
     $images = bp_attachments_get_allowed_types('image/');
     foreach ($images as $image) {
         if ('image' !== wp_ext2type($image)) {
             $not_image = $image;
         }
     }
     $this->assertTrue(empty($not_image));
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:18,代码来源:functions.php


示例10: _process

 function _process($dom)
 {
     // Scan all the array elements, top to bottom
     $total = count($dom);
     for ($d = 0; $d < $total; ++$d) {
         $processed = FALSE;
         $element = $dom[$d];
         if (!is_array($element)) {
             continue;
         }
         $element_key = key($element);
         if ($element_key != 'text') {
             $element_val = $element[$element_key];
             /**
              * Special elements are: 
              * img, embed, object, a tags are special since they are used as placeholders for 
              * plugins, providing them with a nice fallback, so we are checking them as well
              */
             if (strtolower($element_key) == 'img') {
                 $GLOBALS['WiziappProfiler']->write("Handling IMG", "WiziappMediaExtractor._process");
                 $processed = $this->_handleImage($element_val, $element);
                 $GLOBALS['WiziappProfiler']->write("Done Handling IMG", "WiziappMediaExtractor._process");
             } elseif (strtolower($element_key) == 'object' || strtolower($element_key) == 'embed') {
                 $GLOBALS['WiziappProfiler']->write("Handling Flash Object", "WiziappMediaExtractor._process");
                 $processed = $this->_handleFlashObjects($element_val, '', $element);
                 $GLOBALS['WiziappProfiler']->write("Done Handling Flash Object", "WiziappMediaExtractor._process");
                 // vimeo might be loaded as an iframe
             } elseif (strtolower($element_key) == 'iframe') {
                 //                    $GLOBALS['WiziappLog']->write('info', ">>> Found iframe::" . print_r($element_val, TRUE), '_process');
                 $GLOBALS['WiziappProfiler']->write("Handling Iframe as Flash Object", "WiziappMediaExtractor._process");
                 $processed = $this->_handleFlashObjects($element_val, '', $element);
                 $GLOBALS['WiziappProfiler']->write("Done Handling Iframe as Flash Object", "WiziappMediaExtractor._process");
             } elseif (strtolower($element_key) == 'a') {
                 /**
                  * Some plugins uses a tags to include sounds and videos, use the built-in
                  * wordpress function to tell us which file it is by it's ext
                  */
                 $GLOBALS['WiziappProfiler']->write("Handling link", "WiziappMediaExtractor._process");
                 $pos = strrpos($element_val['attributes']['href'], '.');
                 if ($pos !== FALSE) {
                     $ext = substr($element_val['attributes']['href'], $pos + 1);
                     $type = wp_ext2type($ext);
                     if ($type == 'audio') {
                         $GLOBALS['WiziappProfiler']->write("Handling audio link", "WiziappMediaExtractor._process");
                         $processed = $this->_handleAudio($element_val['attributes']['href'], $element_val, $element);
                         $GLOBALS['WiziappProfiler']->write("Done Handling audio link", "WiziappMediaExtractor._process");
                     }
                 }
                 $GLOBALS['WiziappProfiler']->write("Done Handling link", "WiziappMediaExtractor._process");
                 // Use the main parsing method
                 /**if ( !$processed ){ - Removing the support for video embed via links
                        $processed = $this->_handleFlashObjects($element_val, $element_val['attributes']['href'], $element);    
                    }*/
             }
             // The childs of this array can be: text, attributes, childs
             if (!empty($element_val['childs']) && !$processed) {
                 //$this->_process($element_val['childs']);
                 $childs = $element_val['childs'];
                 $this->_process($childs);
             }
         }
     }
 }
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:63,代码来源:media_extractor.php


示例11: medialink_func


//.........这里部分代码省略.........
SEARCHFORM;
    //MoviePlayerContainer
    $movieplayercontainer = <<<MOVIEPLAYERCONTAINER
<div id="PlayerContainer-medialink">
<video controls autoplay style="width: 100%;">
<source src="{$prevfile}">
<source src="{$prevfile_nosuffix}{$suffix_2}">
</video>
</div>
MOVIEPLAYERCONTAINER;
    //MusicPlayerContainer
    $musicplayercontainer = <<<MUSICPLAYERCONTAINER
<div id="PlayerContainer-medialink">
<audio controls autoplay>
<source src="{$prevfile}">
<source src="{$prevfile_nosuffix}{$suffix_2}">
<div id="FlashContainer"></div>
</audio>
</div>
MUSICPLAYERCONTAINER;
    wp_enqueue_style('for medialink', MEDIALINK_PLUGIN_URL . '/css/medialink.css');
    if ($set === 'all') {
        if (!empty($selectedfilename)) {
            $html .= '<h2>' . $selectedfilename . '</h2>';
        }
    } else {
        if ($set != 'document' && !empty($selectedfilename)) {
            $html .= '<h2>' . $selectedfilename . '</h2>';
        }
    }
    $fparamexts = explode('.', $fparam);
    $fparamext = end($fparamexts);
    if (!empty($fparam)) {
        if (wp_ext2type($fparamext) === 'video') {
            $html .= $movieplayercontainer;
        } else {
            if (wp_ext2type($fparamext) === 'audio') {
                $html .= $musicplayercontainer;
            }
        }
    }
    $linkfiles_begin = NULL;
    $linkfiles_end = NULL;
    $archiveselectbox_begin = NULL;
    $archiveselectbox_end = NULL;
    $linkpages_begin = NULL;
    $linkpages_end = NULL;
    $sortlink_begin = NULL;
    $sortlink_end = NULL;
    $searchform_begin = NULL;
    $searchform_end = NULL;
    $rssfeeds_icon = NULL;
    if ($set === 'album' || $set === 'slideshow') {
        $linkfiles_begin = '<div class = "medialink">';
        $linkfiles_end = '</div><br clear=all>';
    } else {
        $linkfiles_begin = '<div class="medialink-list"><ul>';
        $linkfiles_end = '</ul></div>';
    }
    $archiveselectbox_begin = '<div align="right">';
    $archiveselectbox_end = '</div>';
    $linkpages_begin = '<p><div class="medialink-pages"><span class="medialink-links">';
    $linkpages_end = '</span></div></p>';
    $sortlink_begin = '<p><div class="medialink-pages"><span class="medialink-links">';
    $sortlink_end = '</span></div></p>';
    $searchform_begin = '<div align="center">';
开发者ID:lpender,项目名称:oort,代码行数:67,代码来源:medialink.php


示例12: extpattern

 function extpattern($suffix_exclude)
 {
     if ($this->set === 'all') {
         $searchtype = 'image|document|spreadsheet|interactive|text|archive|code';
     } else {
         if ($this->set === 'album' || $this->set === 'slideshow') {
             $searchtype = 'image';
         } else {
             if ($this->set === 'document') {
                 $searchtype = 'document|spreadsheet|interactive|text|archive|code';
             }
         }
     }
     $mimes = wp_get_mime_types();
     $extpattern = NULL;
     foreach ($mimes as $ext => $mime) {
         if (strpos($ext, '|')) {
             $exts = explode('|', $ext);
             foreach ($exts as $ext2) {
                 if (preg_match("/" . $searchtype . "/", wp_ext2type($ext2))) {
                     if (!empty($suffix_exclude) && preg_match("/" . $suffix_exclude . "/i", $ext2)) {
                     } else {
                         $extpattern .= $ext2 . ',' . strtoupper($ext2) . ',';
                     }
                 }
             }
         } else {
             if (preg_match("/" . $searchtype . "/", wp_ext2type($ext))) {
                 if (!empty($suffix_exclude) && preg_match("/" . $suffix_exclude . "/i", $ext)) {
                 } else {
                     $extpattern .= $ext . ',' . strtoupper($ext) . ',';
                 }
             }
         }
     }
     $extpattern = substr($extpattern, 0, -1);
     return $extpattern;
 }
开发者ID:lpender,项目名称:oort,代码行数:38,代码来源:MediaLink.php


示例13: gm_get_media_image

 /**
  * Get an HTML img element representing an image attachment
  * @see  add_image_size()
  * @see  wp_get_attachment_image()
  * @uses apply_filters() Calls 'gm_get_attachment_image_attributes' hook on attributes array
  *
  * @param int|object $item Image object.
  * @param string $size Optional, default is empty string, could be 'thumb', 'original'
  * @param bool $cover Optional, try to get cover url
  * @param bool|string $default Optional, return if no cover
  *
  * @return string img url
  */
 function gm_get_media_image($item, $size = '', $cover = true, $default = false)
 {
     global $gmDB, $gmGallery;
     if (!is_object($item)) {
         $item = $gmDB->get_gmedia($item);
     }
     $type = explode('/', $item->mime_type);
     if ('image' == $type[0]) {
         $type_folder = $this->upload['url'] . '/' . $gmGallery->options['folder'][$type[0]];
         switch ($size) {
             case 'thumb':
                 $size_folder = '/thumb/';
                 break;
             case 'original':
                 $size_folder = '/original/';
                 break;
             case 'web':
             default:
                 $size_folder = '/';
                 break;
         }
         $image = $type_folder . $size_folder . $item->gmuid;
     } else {
         $ext = ltrim(strrchr($item->gmuid, '.'), '.');
         if (!($type = wp_ext2type($ext))) {
             $type = 'application';
         }
         $image = $this->gmedia_url . '/admin/images/' . $type . '.png';
         if ($cover) {
             $cover = $gmDB->get_metadata('gmedia', $item->ID, 'cover', true);
             if (!empty($cover)) {
                 if ($this->is_digit($cover)) {
                     $image = $this->gm_get_media_image((int) $cover, $size, false);
                 } elseif (false !== filter_var($cover, FILTER_VALIDATE_URL)) {
                     return $cover;
                 }
             } elseif (false !== $default) {
                 return $default;
             }
         }
     }
     return $image;
 }
开发者ID:HugoLS,项目名称:Variation,代码行数:56,代码来源:core.php


示例14: check_extension

 /**
  * Checks whether a file extension is among the accepted file types.
  *
  * @since 0.5.0
  * @param string $extension the file extension to check
  * @param string|array $accepted_types a string or an array of accepted types (default is 'all' to allow everything)
  * @return bool whether the file type is valid
  */
 protected function check_extension($extension, $accepted_types = 'all')
 {
     if ('all' == $accepted_types || !$accepted_types) {
         return true;
     }
     if (!is_array($accepted_types)) {
         $accepted_types = array($accepted_types);
     }
     // check the file extension
     if (in_array(strtolower($extension), $accepted_types)) {
         return true;
     }
     // check the file type (not MIME type!)
     $type = wp_ext2type($extension);
     if ($type !== null && in_array($type, $accepted_types)) {
         return true;
     }
     // check the file MIME type (and first part of MIME type)
     $allowed_mime_types = $this->get_all_mime_types();
     if (isset($allowed_mime_types[$extension])) {
         if (in_array($allowed_mime_types[$extension], $accepted_types)) {
             return true;
         }
         $general_type = explode('/', $allowed_mime_types[$extension])[0];
         if (in_array($general_type, $accepted_types)) {
             return true;
         }
     }
     return false;
 }
开发者ID:felixarntz,项目名称:wpdlib,代码行数:38,代码来源:Media.php


示例15: wf_info_file

 /**
  * Creates array of information about file based on filename.
  * IMPORTANT - Used internally by Wonderflux.
  *
  * Filters available:
  * wflux_ext_img - array of image file extensions
  *
  * @since	1.1
  * @version	1.1
  *
  * @param	[string] $filename		REQUIRED File name with extension (no path)
  * @return	[array]					ext,type,nicetype,playable
  */
 function wf_info_file($filename = '')
 {
     if (empty($filename)) {
         return false;
     }
     $info = wp_check_filetype($filename);
     $file_ext = !empty($info) ? explode('.', $filename) : '';
     $file_nice = wp_ext2type(array_pop($file_ext));
     // wp_ext2type doesn't have functionality to detect image type file (WordPress 3.6)
     // See http://core.trac.wordpress.org/ticket/25261 for patch submitted to address this - may get fixed?!
     // TODO: Check if patch accepted and incorporated in future release of WordPress
     $img_types = apply_filters('wflux_ext_img', array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico'));
     $file_nice = empty($file_nice) && in_array($info['ext'], $img_types) ? 'image' : $file_nice;
     $info['nicetype'] = $file_nice;
     $info['playable'] = in_array($file_nice, array('video', 'audio')) ? 'Y' : 'N';
     return $info;
 }
开发者ID:Tanver186,项目名称:Wonderflux,代码行数:30,代码来源:wf-helper-functions.php


示例16: fw_multi_ext2type

/**
 * Return types from file extensions ex : input array( 'png', 'jpg', 'zip' ) => output : array( 'image', 'archive' ).
 *
 * @see wp_ext2type() function.
 *
 * @param array $ext_array
 *
 * @return array
 */
function fw_multi_ext2type($ext_array = array())
{
    $type_collector = array();
    foreach ($ext_array as $ext) {
        $type = wp_ext2type($ext);
        if (!in_array($type, $type_collector)) {
            $type_collector[] = $type;
        }
    }
    return $type_collector;
}
开发者ID:northpen,项目名称:northpen,代码行数:20,代码来源:general.php


示例17: add_anchor_tag_gallery

 function add_anchor_tag_gallery($link, $id, $size, $permalink, $icon, $text)
 {
     if (preg_match_all("/\\s+href\\s*=\\s*([\"\\']?)([^\\s\"\\'>]+)(\\1)/ims", $link, $result) !== false) {
         foreach ($result[0] as $value) {
             $exts = explode('.', substr($value, 0, -1));
             $ext = end($exts);
             $ext2type = wp_ext2type($ext);
             if ($ext2type === 'image') {
                 $titlename = ' title="' . get_the_title($id) . '"';
                 if ($this->effect === 'colorbox') {
                     // colorbox
                     $class_name = 'class="boxersandswipers"';
                     $link = str_replace('<a', '<a ' . $class_name . $titlename, $link);
                 } else {
                     if ($this->effect === 'slimbox') {
                         //slimbox
                         $rel_name = 'rel="boxersandswipers"';
                         $link = str_replace('<a', '<a ' . $rel_name . $titlename, $link);
                     } else {
                         if ($this->effect === 'nivolightbox') {
                             //nivolightbox
                             $rel_name = 'data-lightbox-gallery="boxersandswipers"';
                             $link = str_replace('<a', '<a ' . $rel_name . $titlename, $link);
                         } else {
                             if ($this->effect === 'imagelightbox') {
                                 //imagelightbox
                                 $rel_name = 'data-imagelightbox="boxersandswipers"';
                                 $link = str_replace('<a', '<a ' . $rel_name . $titlename, $link);
                             } else {
                                 if ($this->effect === 'photoswipe') {
                                     //photoswipe
                                     $class_name = 'class="boxersandswipers" ';
                                     $link = str_replace('<a', '<a ' . $class_name, $link);
                                 } else {
                                     if ($this->effect === 'swipebox') {
                                         //swipebox
                                         $rel_name = 'rel="boxers-and-swipers"';
                                         $class_name = ' class="boxersandswipers"';
                                         $link = str_replace('<a', '<a ' . $rel_name . $class_name . $titlename, $link);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $link;
 }
开发者ID:alpual,项目名称:sweekswatercolors,代码行数:50,代码来源:BoxersAndSwipers.php


示例18: wp_media_upload_handler

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @return mixed
 */
function wp_media_upload_handler()
{
    $errors = array();
    $id = 0;
    if (isset($_POST['html-upload']) && !empty($_FILES)) {
        check_admin_referer('media-form');
        // Upload File button was clicked
        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    if (!empty($_POST['insertonlybutton'])) {
        $src = $_POST['src'];
        if (!empty($src) && !strpos($src, '://')) {
            $src = "http://{$src}";
        }
        if (isset($_POST['media_type']) && 'image' != $_POST['media_type']) {
            $title = esc_html(wp_unslash($_POST['title']));
            if (empty($title)) {
                $title = esc_html(basename($src));
            }
            if ($title && $src) {
                $html = "<a href='" . esc_url($src) . "'>{$title}</a>";
            }
            $type = 'file';
            if (($ext = preg_replace('/^.+?\\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext)) && ('audio' == $ext_type || 'video' == $ext_type)) {
                $type = $ext_type;
            }
            $html = apply_filters($type . '_send_to_editor_url', $html, esc_url_raw($src), $title);
        } else {
            $align = '';
            $alt = esc_attr(wp_unslash($_POST['alt']));
            if (isset($_POST['align'])) {
                $align = esc_attr(wp_unslash($_POST['align']));
                $class = " class='align{$align}'";
            }
            if (!empty($src)) {
                $html = "<img src='" . esc_url($src) . "' alt='{$alt}'{$class} />";
            }
            $html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
        }
        return media_send_to_editor($html);
    }
    if (!empty($_POST)) {
        $return = media_upload_form_handler();
        if (is_string($return)) {
            return $return;
        }
        if (is_array($return)) {
            $errors = $return;
        }
    }
    if (isset($_POST['save'])) {
        $errors['upload_notice'] = __('Saved.');
        return media_upload_gallery();
    }
    if (isset($_GET['tab']) && $_GET['tab'] == 'type_url') {
        $type = 'image';
        if (isset($_GET['type']) && in_array($_GET['type'], array('video', 'audio', 'file'))) {
            $type = $_GET['type'];
        }
        return wp_iframe('media_upload_type_url_form', $type, $errors, $id);
    }
    return wp_iframe('media_upload_type_form', 'image', $errors, $id);
}
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:75,代码来源:media.php


示例19: hacklogra_upyun_media_upload_handler

/**
 * {@internal Missing Short Description}}
 *
 * @since 1.4.0
 *
 * @return unknown
 */
function hacklogra_upyun_media_upload_handler()
{
    global $is_iphone;
    $errors = array();
    $id = 0;
    if (isset($_GET['code']) && isset($_GET['message']) && isset($_GET['url']) && isset($_GET['time'])) {
        $id = hacklogra_upyun::handle_form_api_upload($_REQUEST['post_id'], $post_data = array());
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    if (!empty($_POST['insertonlybutton'])) {
        $src = $_POST['src'];
        if (!empty($src) && !strpos($src, '://')) {
            $src = "http://{$src}";
        }
        if (isset($_POST['media_type']) && 'image' != $_POST['media_type']) {
            $title = esc_html(stripslashes($_POST['title']));
            if (empty($title)) {
                $title = esc_html(basename($src));
            }
            if ($title && $src) {
                $html = "<a href='" . esc_url($src) . "'>{$title}</a>";
            }
            $type = 'file';
            if (($ext = preg_replace('/^.+?\\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext)) && ('audio' == $ext_type || 'video' == $ext_type)) {
                $type = $ext_type;
            }
            $html = 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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