S
S
Sergey Defactov2017-01-13 13:58:02
css
Sergey Defactov, 2017-01-13 13:58:02

How to style Thumb on an image?

the news displays thumb pictures through

<?php if($entries->image):?>
    <?php $src = $entries->image->getSmallThumbLink(); ?>
      <?php if($src) : ?>
          <?php
          $tagAlt = CHtml::encode($entries->getStrByLang('title')); 
          if (issetModule('seo') && isset($entries->image->image_seo) && $entries->image->image_seo->getStrByLang('alt')) {
            $tagAlt = CHtml::encode($entries->image->image_seo->getStrByLang('alt'));
          }
          ?>
       <?php echo CHtml::link(CHtml::image($src, $tagAlt),array('style'=>'border-radius: 50%;')); ?>

in the controller there is such a code, but not all images have the same width
class EntriesImage extends ParentModel {
  public $imageInstance = null;
  public $path = 'webroot.uploads.entries';

  const SMALL_THUMB_WIDTH = 211;
  const SMALL_THUMB_HEIGHT = 180;

How to set the style for images for example width:150px height: 100px ;
so that all news thumb pictures have this style

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nastya Sukharik, 2017-01-13
@cashloveyou

htmlOptions is the third option in CHtml::image
public static string image(string $src, string $alt='', array $htmlOptions=array ( ))
For example when using array('class' => 'my-class' , 'target' => '_blank') as htmlOptions it will result in the html attributes rendered like this: class="my-class" target="_blank".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question