php - Drupal 8 change image style in first row on views list -
i have created view displays on page 10 newest article. have in row 2 fields: image , content. in settings of image field chose image style (for example: medium). how can change image style (example: large) in first row?
i have tried in preprocess don't know stored information image style:
function theme_preprocess_views_view_unformatted__lista_depesz_default(&$variables) { $view = $variables['view']; $rows = $variables['rows']; $style = $view->style_plugin; $options = $style->options; $variables['default_row_class'] = !empty($options['default_row_class']); foreach ($rows $id => $row) { $variables['rows'][$id] = array(); $variables['rows'][$id]['content'] = $row; $variables['rows'][$id]['attributes'] = new attribute(); if ($row_class = $view->style_plugin->getrowclass($id)) { $variables['rows'][$id]['attributes']->addclass($row_class); } if ($id == 0 && $row['content']['#row']->_entity->field_image[0] != null) { //some php code change image style } } }
regards
regarding code , explanations, i'm not sure understand trying achieve.
1/ try add css class 1st image of view. why not using following css path .my_view .first img {}
2/ if try call image style, can create view 1st item, or promoted? second view rest of items ?
3/ if try call image style, can without code. install module http://drupal.org/project/views_conditional add 2 images 2 different image style, , apply condition inside condition fieldset.
i prefer solution 3 because it's pure drupal build.
i hope helps.
cheers
Comments
Post a Comment