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


PHP image_get_info函数代码示例

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


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

示例1: cstark_preprocess_node

function cstark_preprocess_node(&$variables)
{
    if (user_access('administer nodes')) {
        $variables['edit_link'] = l(t('Edit'), 'node/' . $variables['nid'] . '/edit');
        if ($variables['type'] == 'painting') {
            $title = $variables['promote'] ? t('Remove from front page') : t('Add to front page');
            $variables['set_as_main_link'] = l($title, 'set-as-main/' . $variables['nid']);
            // Facebook share.
            $url = url('node/' . $variables['nid'], array('absolute' => TRUE));
            $variables['share_link'] = l(t('Share'), "http://www.facebook.com/sharer.php?u={$url}", array('attributes' => array('class' => array('facebook'))));
        }
    }
    if ($variables['type'] == 'painting') {
        $wrapper = entity_metadata_wrapper('node', $variables['nid']);
        if ($image = $wrapper->field_image->value()) {
            $element = array('#tag' => 'meta', '#attributes' => array('property' => 'og:image', 'content' => file_create_url($image['uri'])));
            drupal_add_html_head($element, 'cstark_painting_image');
            $element = array('#tag' => 'meta', '#attributes' => array('property' => 'og:title', 'content' => $wrapper->label()));
            drupal_add_html_head($element, 'cstark_painting_title');
        }
    }
    if ($variables['type'] == 'painting' && !drupal_is_front_page()) {
        $variables['pager'] = shapira_get_painting_pager($variables['nid']);
    }
    if ($variables['type'] != 'news') {
        $variables['hide_title'] = true;
    }
    if ($variables['type'] == 'painting') {
        if ($variables['field_image']) {
            $info = image_get_info(image_style_path('painting', $variables['field_image'][0]['uri']));
            $variables['node_width'] = $info['width'];
        }
    }
}
开发者ID:bitamar,项目名称:rashapira,代码行数:34,代码来源:template.php

示例2: buildDescription

 /**
  * Build the search row description.
  *
  * If there is a "result_description", run it thro token_replace.
  *
  * @param object $data
  *   An entity object that will be used in the token_place function.
  *
  * @see token_replace()
  */
 function buildDescription($data)
 {
     $description_array = array();
     //Get image info.
     $imageinfo = image_get_info($data->uri);
     if ($this->conf['image_extra_info']['thumbnail']) {
         $image = $imageinfo ? theme_image_style(array('width' => $imageinfo['width'], 'height' => $imageinfo['height'], 'style_name' => 'linkit_thumb', 'path' => $data->uri)) : '';
     }
     if ($this->conf['image_extra_info']['dimensions'] && !empty($imageinfo)) {
         $description_array[] = $imageinfo['width'] . 'x' . $imageinfo['height'] . 'px';
     }
     $description_array[] = parent::buildDescription($data);
     if ($this->conf['show_scheme']) {
         $description_array[] = file_uri_scheme($data->uri) . '://';
     }
     $description = (isset($image) ? $image : '') . implode('<br />', $description_array);
     return $description;
 }
开发者ID:Probo-Demos,项目名称:drupal_github,代码行数:28,代码来源:linkit-plugin-file.class.php

示例3: image_gd_resize

/**
 * Scale an image to the specified size using GD.
 */
function image_gd_resize($source, $destination, $width, $height)
{
    if (!file_exists($source)) {
        return false;
    }
    $info = image_get_info($source);
    if (!$info) {
        return false;
    }
    $im = image_gd_open($source, $info['extension']);
    if (!$im) {
        return false;
    }
    $res = imageCreateTrueColor($width, $height);
    imageCopyResampled($res, $im, 0, 0, 0, 0, $width, $height, $info['width'], $info['height']);
    $result = image_gd_close($res, $destination, $info['extension']);
    imageDestroy($res);
    imageDestroy($im);
    return $result;
}
开发者ID:naehrstoff,项目名称:photo-promenade,代码行数:23,代码来源:image.php

示例4: image_file_download

 function image_file_download($file)
 {
     $size = image_get_info(file_create_path($file));
     if ($size) {
         $modified = filemtime(file_create_path($file));
         //apache only
         $request = getallheaders();
         if (isset($request['If-Modified-Since'])) {
             //remove information after the semicolon and form a timestamp
             $request_modified = explode(';', $request['If-Modified-Since']);
             $request_modified = strtotime($request_modified[0]);
         }
         // Compare the mtime on the request to the mtime of the image file
         if ($modified <= $request_modified) {
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
         //enable caching on this url for proxy servers
         $headers = array('Content-Type: ' . $size['mime_type'], 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $modified) . ' GMT', 'Cache-Control: public');
         return $headers;
     }
 }
开发者ID:naliduo,项目名称:ThinkSNS,代码行数:22,代码来源:AttachAction.class.php

示例5: theme_icon_RENDER_HOOK

/**
 * Implements theme_icon_RENDER_HOOK().
 *
 * Return an image of the requested icon.
 *
 * @param array $variables
 *   An associative array containing:
 *   - attributes: Associative array of HTML attributes.
 *   - bundle: An associative array containing various properties.
 *   - icon: Name of the icon requested from the above bundle.
 *
 * @return string
 *   HTML markup for the requested icon.
 *
 * @see hook_icon_bundles()
 * @see theme_icon_image()
 */
function theme_icon_RENDER_HOOK($variables)
{
    $output = '';
    $bundle = $variables['bundle'];
    $icon = $variables['icon'];
    $image = $bundle['path'] . '/' . $icon . '.' . $bundle['settings']['extension'];
    if (file_exists($image) && ($info = image_get_info($image))) {
        $output = theme('image', array('path' => $image, 'height' => $info['height'], 'width' => $info['width'], 'attributes' => $variables['attributes']));
    }
    return $output;
}
开发者ID:alfredpp,项目名称:travel,代码行数:28,代码来源:icon.api.php

示例6: current_path

$base = $GLOBALS['base_url'] . '/';
$path = current_path();
$alias = drupal_lookup_path('alias', $path);
if ($alias) {
    $url = $base . $alias;
} else {
    $url = $base . $path;
}
?>
<meta property="og:url" content="<?php 
print $url;
?>
">
<?php 
if ($thumbnail_image) {
    $result = image_get_info($thumbnail_image);
    ?>
<!--
  <PageMap>
    <DataObject type="thumbnail">
      <Attribute name="src" value="<?php 
    print file_create_url($thumbnail_image);
    ?>
"/>
      <Attribute name="width" value="<?php 
    print $result['width'];
    ?>
"/>
      <Attribute name="height" value="<?php 
    print $result['height'];
    ?>
开发者ID:10corp,项目名称:NMU-Zen,代码行数:31,代码来源:html.tpl.php

示例7: userPictureFromLdapEntry

 /**
  * @param ldap entry array $ldap_entry
  *
  * @return drupal file object image user's thumbnail or FALSE if none present or ERROR happens.
  */
 public function userPictureFromLdapEntry($ldap_entry, $drupal_username = FALSE)
 {
     if ($ldap_entry && $this->picture_attr) {
         //Check if ldap entry has been provisioned.
         $thumb = isset($ldap_entry[$this->picture_attr][0]) ? $ldap_entry[$this->picture_attr][0] : FALSE;
         if (!$thumb) {
             return FALSE;
         }
         //Create md5 check.
         $md5thumb = md5($thumb);
         /**
          * If existing account already has picture check if it has changed if so remove old file and create the new one
          * If picture is not set but account has md5 something is wrong exit.
          */
         if ($drupal_username && ($account = user_load_by_name($drupal_username))) {
             if ($account->uid == 0 || $account->uid == 1) {
                 return FALSE;
             }
             if (isset($account->picture)) {
                 // Check if image has changed
                 if (isset($account->data['ldap_user']['init']['thumb5md']) && $md5thumb === $account->data['ldap_user']['init']['thumb5md']) {
                     //No change return same image
                     return $account->picture;
                 } else {
                     //Image is different check wether is obj/str and remove fileobject
                     if (is_object($account->picture)) {
                         file_delete($account->picture, TRUE);
                     } elseif (is_string($account->picture)) {
                         $file = file_load(intval($account->picture));
                         file_delete($file, TRUE);
                     }
                 }
             } elseif (isset($account->data['ldap_user']['init']['thumb5md'])) {
                 watchdog('ldap_server', "Some error happened during thumbnailPhoto sync");
                 return FALSE;
             }
         }
         //Create tmp file to get image format.
         $filename = uniqid();
         $fileuri = file_directory_temp() . '/' . $filename;
         $size = file_put_contents($fileuri, $thumb);
         $info = image_get_info($fileuri);
         unlink($fileuri);
         // create file object
         $file = file_save_data($thumb, 'public://' . variable_get('user_picture_path') . '/' . $filename . '.' . $info['extension']);
         $file->md5Sum = $md5thumb;
         // standard Drupal validators for user pictures
         $validators = array('file_validate_is_image' => array(), 'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')), 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024));
         $errors = file_validate($file, $validators);
         if (empty($errors)) {
             return $file;
         } else {
             foreach ($errors as $err => $err_val) {
                 watchdog('ldap_server', "Error storing picture: %{$err}", "%{$err_val}", WATCHDOG_ERROR);
             }
             return FALSE;
         }
     }
 }
开发者ID:tierce,项目名称:ppbe,代码行数:64,代码来源:LdapServer.class.php

示例8: tfd_image_size

function tfd_image_size($filepath, $preset, $asHtml = TRUE)
{
    if (is_array($filepath)) {
        $filepath = $filepath['filepath'];
    }
    $info = image_get_info(image_style_url($preset, $filepath));
    $attr = array('width' => (string) $info['width'], 'height' => (string) $info['height']);
    if ($asHtml) {
        return drupal_attributes($attr);
    } else {
        return $attr;
    }
}
开发者ID:sulav,项目名称:TFD7,代码行数:13,代码来源:Extension.php

示例9: field_get_items

    }
    if ($show_left_sidebar) {
        $style = 'v2_big';
    } else {
        $style = 'v2_article_large';
    }
}
$field_main_image = field_get_items('node', $node, 'field_main_image');
$image_style = image_style_load($style);
$width = '100%';
$height = '100%';
$w = array();
$h = array();
//$path = file_create_url($field_main_image[0]['uri']);
$path = image_style_path($style, $field_main_image[0]['uri']);
$image_info = image_get_info($path);
if (!empty($image_info['width'])) {
    $w[] = (int) $image_info['width'];
}
if (!empty($image_info['height'])) {
    $h[] = (int) $image_info['height'];
}
foreach ($image_style['effects'] as $effect) {
    if (!empty($effect['data']['width'])) {
        $w[] = (int) $effect['data']['width'];
    }
    if (!empty($effect['data']['height'])) {
        $h[] = (int) $effect['data']['height'];
    }
}
if (!empty($h)) {
开发者ID:johnedelatorre,项目名称:fusion,代码行数:31,代码来源:node--image--node_embed.tpl.php

示例10: getImages

 /**
  * Helper function to get all the images from the configured folder.
  */
 private function getImages()
 {
     if ($files = cache_get('devel_image_provider_local')) {
         return $files->data;
     }
     $files = array();
     $count = 1;
     // Limiting number of images to find to 100.
     // @TODO: add this as a setting.
     $max_count = 100;
     // Remove trailing slash.
     $dir = rtrim($this->settings['devel_image_provider_path'], '/');
     if (is_dir($dir) && ($handle = opendir($dir))) {
         while (FALSE !== ($filename = readdir($handle)) && $count <= $max_count) {
             $path = "{$dir}/{$filename}";
             if ($filename[0] != '.' && preg_match('/.*\\.(jpg|jpeg|png)$/i', $filename) && ($image = image_get_info($path))) {
                 $file = new stdClass();
                 $file->uri = file_stream_wrapper_uri_normalize($path);
                 $file->filename = $filename;
                 $file->filemime = $image['mime_type'];
                 $file->name = pathinfo($filename, PATHINFO_FILENAME);
                 $files[$file->uri] = $file;
                 $count++;
             }
         }
         closedir($handle);
     }
     cache_set('devel_image_provider_local', $files, 'cache', CACHE_TEMPORARY);
     return $files;
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:33,代码来源:LocalFolderProvider.class.php

示例11: listFor

 /**
  * @see \ResponsiveImages\SrcsetGeneratorInterface
  *
  * @param string    $uri
  *   Drupal URI to the original image file.
  * @param RImg\Size $size
  *
  * @return RImg\Src[]
  */
 public function listFor($uri, RImg\Size $size)
 {
     $styles = $this->stylesMatchingSize($size);
     # By default Drupal doesn't provide an image style that crops an image to
     # an aspect ratio without potentially upscaling it. If the original image is
     # smaller than the styles that are returned we aren't providing any better
     # quality. Better to just allow only one larger than the original, or even
     # the original if it matches the aspect ratio.
     $image = image_get_info($uri);
     if ($image) {
         $styles = F\partition($styles, function ($style) use($image, $size) {
             return $style->width < $image['width'];
         });
         if ($size->matchesAspectRatio($image['width'] / $image['height']) and (!empty($styles[1]) and F\head($styles[1])->width != $image['width'] or $image['width'] <= $size->getMaxWidth() * 2)) {
             $styles[0][] = (object) ['name' => null, 'width' => $image['width'], 'height' => $image['height'], 'firm' => true];
         } else {
             if (!empty($styles[1])) {
                 $styles[0][] = F\head($styles[1]);
             }
         }
         $styles = $styles[0];
     }
     return F\map($styles, function ($style) use($uri) {
         $url = $style->name ? image_style_url($style->name, $uri) : file_create_url($uri);
         return new RImg\Src($url, $style->width);
     });
 }
开发者ID:RightThisMinute,项目名称:responsive-images-php,代码行数:36,代码来源:DrupalImageStyle.php

示例12: beats_imagecache

function beats_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {


  if((in_array($presetname, array('user_avatar','48x48','189x245' , 'celebrity_80x80'
  )) || !$presetname) && (!file_exists($path) || !$path)){


    $path = drupal_get_path('theme','3beats').'/images/defaults_img.png';
  }
  // Check is_null() so people can intentionally pass an empty array of
  // to override the defaults completely.
  if (is_null($attributes)) {
    $attributes = array('class' => 'imagecache imagecache-'. $presetname);
  }
  if ($getsize && ($image = image_get_info(imagecache_create_path($presetname, $path)))) {
    $attributes['width'] = $image['width'];
    $attributes['height'] = $image['height'];
  }

  $attributes = drupal_attributes($attributes);

  $imagecache_url = $presetname ? imagecache_create_url($presetname, $path) : $path;
  return '<img src="'. $imagecache_url .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
}
开发者ID:rkern21,项目名称:threebeats,代码行数:24,代码来源:template.php

示例13: image_get_info

<?php

$name = $fields['name']->content;
$job = $fields['field_job_position']->content;
$email = $fields['mail']->content;
$colour = $fields['field_colour']->content;
$uri = $fields['uri'];
$imageinfo = image_get_info($uri->raw);
$variables = array('style_name' => 'our_people', 'path' => $uri->raw, 'width' => $imageinfo['width'], 'height' => $imageinfo['height'], 'alt' => strip_tags($name));
$photo = theme_image_style($variables);
?>
<div class="teamBlock column <?php 
print $zebra;
?>
">
      <div class="teamImage" style="background-color:<?php 
print $colour;
?>
"><?php 
print $photo;
?>
        <div class="teamName">
        	<h2><?php 
print $name;
?>
</h2>
		    <h3><?php 
print $job;
?>
</h3>
		    <ul class="socialLinksTeam">
开发者ID:ApsGitAdmin,项目名称:APS,代码行数:31,代码来源:views-view-fields--our-people.tpl.php

示例14: url

    <!--start parallax 6-->
    <?php 
    if ($file = file_load(theme_get_setting('parallax_bg_region6_image', 'surreal'))) {
        ?>
    <div id="parallax-6" class="parallax fixed" style="background: url('<?php 
        print file_create_url($file->uri);
        ?>
')"> 
      <div class="quoteWrap">
        <div class="quote">
          <div class="container">
            <?php 
        if ($file = file_load(theme_get_setting('parallax_fg_region6_image', 'surreal'))) {
            ?>
            <?php 
            $fileinfo = image_get_info(file_create_url($file->uri));
            ?>
            <div class="sixteen columns"> 
              <img height="<?php 
            print $fileinfo['height'];
            ?>
" width="<?php 
            print $fileinfo['width'];
            ?>
" class="cutout" src="<?php 
            print file_create_url($file->uri);
            ?>
" />
            </div>
            <?php 
        }
开发者ID:ApsGitAdmin,项目名称:APS,代码行数:31,代码来源:page.tpl.php

示例15: phptemplate_img_assist_inline

/**
 * Support for image_annotate on img_assist inserted images
 *
 */
function phptemplate_img_assist_inline($node, $size, $attributes)
{
    $caption = '';
    if ($attributes['title'] && $attributes['desc']) {
        $caption = '<strong>' . $attributes['title'] . ': </strong>' . $attributes['desc'];
    } elseif ($attributes['title']) {
        $caption = '<strong>' . $attributes['title'] . '</strong>';
    } elseif ($attributes['desc']) {
        $caption = $attributes['desc'];
    }
    // Change the node title because img_assist_display() uses the node title for
    // alt and title.
    $node->title = strip_tags($caption);
    // --------------------------
    if (user_access('view image annotations') || user_access('create image annotations') || user_access('administer image annotations')) {
        // Retrieve all the annotations for that image field
        // We sort by area (height*width) to make sure small annotations are always on the top and avoid having some unhoverable ones
        $result = db_query('SELECT i.*, c.uid, c.comment, u.name FROM {image_annotate} i INNER JOIN {comments} c ON i.cid = c.cid JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d ORDER BY (i.size_height*i.size_width) ASC', $node->nid);
        // Build the array of notes settings
        global $user;
        $notes = array();
        while ($note = db_fetch_object($result)) {
            $editable = user_access('administer image annotations') || user_access('create image annotations') && $note->uid && $note->uid == $user->uid;
            $author = theme('username', $note);
            $text = check_plain($note->comment);
            // . '"<span class="author"> '. t('by') .' '. $author . '</span>';
            //      if (user_access('access comments')) {
            //        $text .= '<span class="actions"> » '. l(t('View comment'), $_GET['q'], array('fragment'=>'comment-'. $note->cid)) .'</span>';
            //      }
            $notes[] = array('aid' => $note->aid, 'cid' => $note->cid, 'uid' => $note->uid, 'height' => $note->size_height, 'width' => $note->size_width, 'top' => $note->position_top, 'left' => $note->position_left, 'text' => $text, 'editable' => FALSE);
        }
        // Build the field settings
        $settings = array(array('nid' => $node->nid, 'field' => 'image', 'notes' => $notes, 'editable' => user_access('administer image annotations') || user_access('create image annotations')));
        module_load_include('module', 'jquery_ui');
        // Load all the JS and CSS magic
        drupal_add_js(array('imageAnnotate' => $settings), 'setting');
        jquery_ui_add(array('ui.resizable', 'ui.draggable'));
        drupal_add_js('misc/collapse.js');
        drupal_add_js(drupal_get_path('module', 'image_annotate') . '/tag.js');
        drupal_add_css(drupal_get_path('module', 'image_annotate') . '/tag.css');
        //BVDM 13/09/09: substitute image-annotate-image for image-annotate-nid-$node->nid to create a unique class per inserted image
        $class = 'imagefield imagefield-image image-annotate-nid-' . $node->nid;
        $img_tag = img_assist_display($node, $size, array('class' => $class));
    } else {
        $img_tag = img_assist_display($node, $size);
    }
    // -----------------------
    // Always define an alignment class, even if it is 'none'.
    $output = '<span class="inline inline-' . $attributes['align'] . '">';
    $link = $attributes['link'];
    $url = '';
    // Backwards compatibility: Also parse link/url in the format link=url,foo.
    if (strpos($link, ',') !== FALSE) {
        list($link, $url) = explode(',', $link, 2);
    } elseif (isset($attributes['url'])) {
        $url = $attributes['url'];
    }
    if ($link == 'node') {
        $output .= l($img_tag, 'node/' . $node->nid, array('html' => TRUE));
    } elseif ($link == 'popup') {
        $popup_size = variable_get('img_assist_popup_label', IMAGE_PREVIEW);
        $info = image_get_info(file_create_path($node->images[$popup_size]));
        $width = $info['width'];
        $height = $info['height'];
        $popup_url = file_create_url($node->images[variable_get('img_assist_popup_label', IMAGE_PREVIEW)]);
        $output .= l($img_tag, $popup_url, array('attributes' => array('onclick' => "launch_popup({$node->nid}, {$width}, {$height}); return false;", 'target' => '_blank'), 'html' => TRUE));
    } elseif ($link == 'url') {
        $output .= l($img_tag, $url, array('html' => TRUE));
    } else {
        $output .= $img_tag;
    }
    if ($caption) {
        if ($attributes['align'] != 'center') {
            $info = image_get_info(file_create_path($node->images[$size['key']]));
            // Reduce the caption width slightly so the variable width of the text
            // doesn't ever exceed image width.
            $width = $info['width'] - 2;
            $output .= '<span class="caption" style="width: ' . $width . 'px;">' . $caption . '</span>';
        } else {
            $output .= '<span class="caption">' . $caption . '</span>';
        }
    }
    $output .= '</span>';
    return $output;
}
开发者ID:haxelsson,项目名称:flm02,代码行数:89,代码来源:template.php


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