将alt属性添加到横幅图片(opencart)

时间:2017-04-28 13:45:06

标签: php opencart banner

在网站上我们有横幅,但没有任何替代文字。

以下是关于如何解决此问题的任何指针的代码?我想可能有alt作为图像名称,如果可能,所以需要找到一种方法来回应它。

还有其他建议吗?我有8个横幅,如果可能的话,请不要介意为每个横幅添加替代文字

<?php if ($module_title){ ?>
<div class="box-heading"><?php echo $module_title; ?></div>
<?php } ?>
<div class="box rich_banner grid_holder">
<?php foreach($sections as $section){ ?>
<div class="banner_<?php echo $columns; ?>">
<div class="image zoom_image_container"><img class="zoom_image" alt="" src="<?php echo $section['image']; ?>" />
<?php echo $section['description']; ?>
</div>
</div>
<?php } ?>
</div>

这会是下面变量的一部分吗?

<?php
class ControllerExtensionModuleCosyoneBanner extends Controller {
    public function index($setting) {


        if(empty($setting['module_title'][$this->config->get('config_language_id')])) {
            $data['module_title'] = false;
        } else if (isset($setting['module_title'][$this->config->get('config_language_id')])) {
            $data['module_title'] = html_entity_decode($setting['module_title'][$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8');
        }

        $data['columns'] = $setting['columns'];

        if (isset($setting['sections'])) {        
            $data['sections'] = array();

            $section_row = 0;

            foreach($setting['sections'] as $section) {
                $this->load->model('tool/image');

                if (isset($section['block'][$this->config->get('config_language_id')])){
                    $block = html_entity_decode($section['block'][$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8');
                } else {
                    $block = false;
                }

                if (isset($section['thumb_image'])){
                $image = 'image/' . $section['thumb_image'];
                } else {
                $image = false;
                }


                $section_row++;

                $data['sections'][] = array(
                    'index'   => $section_row,
                    'description'   => $block,
                    'image' => $image
                );
            }

            return $this->load->view('extension/module/cosyone_banner', $data);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可以在alt中使用该说明,我认为可用的是最佳解决方案。

<div class="image zoom_image_container"><img class="zoom_image" alt="<?php echo $section['description']; ?>" src="<?php echo $section['image']; ?>" />