<legend id='CGSNo'><style id='CGSNo'><dir id='CGSNo'><q id='CGSNo'></q></dir></style></legend>

      <bdo id='CGSNo'></bdo><ul id='CGSNo'></ul>
    <tfoot id='CGSNo'></tfoot>

  1. <small id='CGSNo'></small><noframes id='CGSNo'>

      <i id='CGSNo'><tr id='CGSNo'><dt id='CGSNo'><q id='CGSNo'><span id='CGSNo'><b id='CGSNo'><form id='CGSNo'><ins id='CGSNo'></ins><ul id='CGSNo'></ul><sub id='CGSNo'></sub></form><legend id='CGSNo'></legend><bdo id='CGSNo'><pre id='CGSNo'><center id='CGSNo'></center></pre></bdo></b><th id='CGSNo'></th></span></q></dt></tr></i><div id='CGSNo'><tfoot id='CGSNo'></tfoot><dl id='CGSNo'><fieldset id='CGSNo'></fieldset></dl></div>
    1. 在使用 imagecache_create_path &amp; 之前使用 Drupal imagecache

      时间:2023-06-22
      <legend id='oqoXI'><style id='oqoXI'><dir id='oqoXI'><q id='oqoXI'></q></dir></style></legend>
          <tbody id='oqoXI'></tbody>

        <tfoot id='oqoXI'></tfoot>

        <i id='oqoXI'><tr id='oqoXI'><dt id='oqoXI'><q id='oqoXI'><span id='oqoXI'><b id='oqoXI'><form id='oqoXI'><ins id='oqoXI'></ins><ul id='oqoXI'></ul><sub id='oqoXI'></sub></form><legend id='oqoXI'></legend><bdo id='oqoXI'><pre id='oqoXI'><center id='oqoXI'></center></pre></bdo></b><th id='oqoXI'></th></span></q></dt></tr></i><div id='oqoXI'><tfoot id='oqoXI'></tfoot><dl id='oqoXI'><fieldset id='oqoXI'></fieldset></dl></div>

        <small id='oqoXI'></small><noframes id='oqoXI'>

                <bdo id='oqoXI'></bdo><ul id='oqoXI'></ul>
              • 本文介绍了在使用 imagecache_create_path &amp; 之前使用 Drupal imagecache 生成图像获取图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 imagecache_create_path() 和 getimagesize() 来获取图像缓存生成的图像的路径及其尺寸.但是,如果这是我们第一次访问该图像尚不存在的页面并且 imagecache_create_path 也不会生成它.

                I'm using imagecache_create_path() and getimagesize() to get the path of a imagecache-generated image and its dimensions. However, if it's the first time we access the page that image doesn't exist yet and imagecache_create_path doesn't generate it either.

                代码如下:

                // we get the image path from a preset (always return the path even if the file doesn't exist)
                $small_image_path = imagecache_create_path('gallery_image_small', $image["filepath"]);
                // I get the image dimensions (only if the file exists already)
                $data_small = list($width, $height, $type, $image_attributes) = @getimagesize($small_image_path);
                

                是否有任何 API 方法来获取路径并生成文件?换句话说,我可以从 PHP 生成图像(使用预设)而不在浏览器中显示它吗?

                Is there any API method to get the path AND generate the file? In other words, can I generate the image (using a preset) from PHP without showing it in the browser?

                提前致谢

                推荐答案

                检查 imagecache_build_derivative() 函数及其在 imagecache.module 中的用法.对于您的情况,它应该大致如下工作:

                Check the imagecache_build_derivative() function and its usage in imagecache.module. For your case, it should work roughly like so:

                $presetname = 'gallery_image_small';
                $preset = imagecache_preset_by_name($presetname);
                $src = $image["filepath"];
                $dst = imagecache_create_path($presetname, $src);
                // Ensure existing derivative or try to create it on the fly
                if (file_exists($dst) || imagecache_build_derivative($preset['actions'], $src, $dst)) {
                  // Do what you need to do with the image
                }
                

                (注意:未经测试的代码,注意错别字和其他错误/疏忽)

                (NOTE: untested code, beware of typos and other errors/oversights)

                这篇关于在使用 imagecache_create_path &amp; 之前使用 Drupal imagecache 生成图像获取图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从网站/cdn 跟踪下载完成情况 下一篇:你能控制钩子的顺序“射击"吗?在 Drupal 中?

                相关文章

              • <legend id='9PFRV'><style id='9PFRV'><dir id='9PFRV'><q id='9PFRV'></q></dir></style></legend>

                <small id='9PFRV'></small><noframes id='9PFRV'>

                <tfoot id='9PFRV'></tfoot>
                    <bdo id='9PFRV'></bdo><ul id='9PFRV'></ul>

                  <i id='9PFRV'><tr id='9PFRV'><dt id='9PFRV'><q id='9PFRV'><span id='9PFRV'><b id='9PFRV'><form id='9PFRV'><ins id='9PFRV'></ins><ul id='9PFRV'></ul><sub id='9PFRV'></sub></form><legend id='9PFRV'></legend><bdo id='9PFRV'><pre id='9PFRV'><center id='9PFRV'></center></pre></bdo></b><th id='9PFRV'></th></span></q></dt></tr></i><div id='9PFRV'><tfoot id='9PFRV'></tfoot><dl id='9PFRV'><fieldset id='9PFRV'></fieldset></dl></div>