联系官方销售客服

1835022288

028-61286886

开发框架 版主:迅睿框架研发组
调用自定义组图的实际图片宽度
类型:迅睿CMS 更新时间:2022-11-03 11:48:43
 <?php if ($zutu) { $key=0; foreach ($zutu as $c) { ?>

                                    { 
                        {php $cc = current($zutu);}
                        href: "{dr_get_file($cc)}",
                        src: "{dr_get_file($c)}", 
                        img: "{dr_get_file($c)}", 
                        width: "237", height: "150", 
                        title: "{$t['title']}" 
                    },
                    <?php $key++;} } ?>


我想调用该图片的宽度的数值,写成100%和auto都不行,系统里有没有这个变量可以调出来?

回帖
  • 迅睿框架联合创始人
    #1楼    迅睿框架联合创始人
    2022-10-28 14:27:17
    Chrome 0
    <?php $size = getimagesize(dr_get_file($c)); ?>
    
    width: "{$size[0]}", height: "{$size[1]}",
    你这又是用循环又是用单一输出,思维太混了,影响页面速度啊
  • 游子2018
    #2楼    游子2018
    2022-10-28 15:00:46
    Chrome 0
    迅睿框架联合创始人
    <?php if ($zutu) { $key=0; foreach ($zutu as $c) { ?>
                          { index: {$key+1}, 
                            href: "{dr_get_file($c)}",
                            src: "{dr_get_file($c)}", 
                            img: "{dr_thumb($c, 200, 200)}", 
                            {php  $size = getimagesize(dr_thumb($c)); }
                            width: "{$size[0]}", height: "150",
                            title: "{$t['title']}" 
                        },
    <?php $key++;} } ?>
    调出来了,感谢大神,确实现在这个代码的执行效率太慢,页面打开明显慢多了,怎么优化一下速度呢?
  • 小波工作室
    #3楼    小波工作室
    2022-10-28 15:06:00
    Chrome 0
    <?php if ($zutu) { $key=0; foreach ($zutu as $c) { ?>
                          { index: {$key+1}, 
                            href: "{dr_get_file($c)}",
                            src: "{dr_get_file($c)}", 
                            img: "{dr_thumb($c, 200, 200)}", 
                            {php  $at=$ci->get_attachment($c);if ($at && $at.attachinfo) { $size=[$at['attachinfo']['width'], $at['attachinfo']['height']];} { $size = getimagesize(dr_get_file($c))}; }
                            width: "{$size[0]}", height: "150",
                            title: "{$t['title']}" 
                        },
    <?php $key++;} } ?>
  • 游子2018
    #4楼    游子2018
    2022-10-28 15:28:12
    Chrome 0
    小波工作室 这个代码执行出现系统故障! 但是我找不出错在哪里?
  • 游子2018
    #5楼    游子2018
    2022-10-28 16:33:48
    Chrome 0
    小波工作室 FCPATH/App/Module/Extends/Home/Module.php : 510 — Phpcmf\View->display ( arguments )503 'params' => ['catid' => $catid],504 'parent' => $parent,505 'related' => $related,506 'urlrule' => \Phpcmf\Service::L('Router')->show_url($this->module, $data, '[page]'),507 'fix_html_now_url' => defined('SC_HTML_FILE') ? dr_url_prefix(\Phpcmf\Service::L('Router')->show_url($this->module, $data, $page), $this->module['dirname'], SITE_ID, \Phpcmf\Service::IS_MOBILE_TPL()) : '', // 修复静态下的当前url变量508 ]);509 \Phpcmf\Service::V()->module($this->module['dirname']);510 !$rt && (\Phpcmf\Service::V()->display(isset($data['template']) && strpos($data['template'], '.html') !== FALSE && is_file(\Phpcmf\Service::V()->get_dir().$data['template']) ? $data['template'] : ($this->module['category'][$data['catid']]['setting']['template']['show'] ? $this->module['category'][$data['catid']]['setting']['template']['show'] : 'show.html')));511 return $data;512 }513 514 // 模块草稿、审核、定时、内容页515 protected function _MyShow($type, $id = 0, $page = 1) {516 517 if (IS_POST) {APPPATH/Controllers/Show.php : 23 — Phpcmf\Home\Module->_Show ( arguments )16 }17 $this->_Show(18 (int)$id,19 [20 'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),21 'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),22 ],23 max(1, (int)\Phpcmf\Service::L('Input')->get('page'))24 );25 }26 27 public function time() {28 $this->_module_init();29 $this->_MyShow(30 'time',SYSTEMPATH/CodeIgniter.php : 832 — Phpcmf\Controllers\Show->index ()825 {826 // If this is a console request then use the input segments as parameters827 $params = defined('SPARKED') ? $this->request->getSegments() : $this->router->params();828 829 if (method_exists($class, '_remap')) {830 $output = $class->_remap($this->method, ...$params);831 } else {832 $output = $class->{$this->method}(...$params);833 }834 835 $this->benchmark->stop('controller');836 837 return $output;838 }839 SYSTEMPATH/CodeIgniter.php : 419 — CodeIgniter\CodeIgniter->runController ( arguments )412 if (! method_exists($controller, '_remap') && ! is_callable([$controller, $this->method], false)) {413 throw PageNotFoundException::forMethodNotFound($this->method);414 }415 416 // Is there a "post_controller_constructor" event?417 Events::trigger('post_controller_constructor');418 419 $returned = $this->runController($controller);420 } else {421 $this->benchmark->stop('controller_constructor');422 $this->benchmark->stop('controller');423 }424 425 // If $returned is a string, then the controller output something,426 // probably a view, instead of echoing it directly. Send it alongSYSTEMPATH/CodeIgniter.php : 326 — CodeIgniter\CodeIgniter->handleRequest ( arguments )319 $this->response->pretend($this->useSafeOutput)->send();320 $this->callExit(EXIT_SUCCESS);321 322 return;323 }324 325 try {326 return $this->handleRequest($routes, $cacheConfig, $returnResponse);327 } catch (RedirectException $e) {328 $logger = Services::logger();329 $logger->info('REDIRECTED ROUTE at ' . $e->getMessage());330 331 // If the route is a 'redirect' route, it throws332 // the exception with the $to as the message333 $this->response->redirect(base_url($e->getMessage()), 'auto', $e->getCode());FCPATH/Fcms/Init.php : 523 — CodeIgniter\CodeIgniter->run ()516 $env = new DotEnv(COREPATH);517 $env->load();518 519 helper('url');520 521 $app = new \Phpcmf\Extend\CodeIgniter(new App());522 $app->initialize();523 $app->run();
  • LandQ
    #6楼    LandQ
    2022-10-31 10:45:13
    Chrome 0
    游子2018 试试这样写
    <?php
    if($zutu)
    {
       $key=0;
       foreach($zutu as $c)
       {
    ?>
    {
    index: {$key+1},
    href: "{dr_get_file($c.file)}",
    src: "{dr_get_file($c.file)}",
    img: "{dr_thumb($c.file, 200, 200)}",
    <?php
    $at = $ci->get_attachment($c.file);
    if ($at && $at.attachinfo)
    {
        $size=[$at['attachinfo']['width'], $at['attachinfo']['height']];
    }
    else
    {
        $size = getimagesize(dr_get_file($c.file));
    }
    ?>
    width: "{$size[0]}",
    height: "{$size[1]}",
    title: "{$t['title']}"
    },
    <?php
          $key++;
       }
    }
    ?>
    满意答案
  • 游子2018
    #7楼    游子2018
    2022-11-03 11:48:43
    Chrome 0
    @LandQ:完美解决,实在高!