0

Is there any possiblity to define another dedicated image style for the teaser of a media gallery node only? I can change the default gallery thumbnail image style but this has also effect on the galleries overview page.

Because I like to create an image slider on the front page with the 5 newest galleries but need the image in another format then the default square thumbnail format.

Is there any possbility to do that so?

3 Answers 3

1

You can create your own image style at admin/config/media/image-styles by click "Add style" link.

Use below code in your template file to fetch particular image style.

$my_style = image_style_url('your-img-style', 'image/uri');
<img src=' . $my_style . '/>

More details about image style.

2
  • Thx for your answer. How would I achieve using the new image style with display suite then? Commented Aug 19, 2015 at 12:55
  • @TiMESPLiNTER, Don't know much about DS.
    – Kalidasan
    Commented Aug 19, 2015 at 12:58
0

Here is what you need to do.

  1. Create a new image style as @kalidasan mentioned in his answer.

  2. Copy the template you are using from Display Suite layout directory and place it in your theme template directory.

  3. Implement hook_ds_pre_render_alter() and from there apply the image_style_url() as mentioned by @kalidasan in his answer.

    $vars['image_style'] = image_style_url('IMAGE_STYLE', 'IMAGE_URI');

  4. Modify the template you copied from Display Suite to render the $image_style you created from #3.

1
  • Thx for your answer. But when I use the DS ds-reset.tpl.php layout. Where do I get the IMAGE_URI from? Commented Aug 21, 2015 at 22:50
0

I managed to achieve what I want. I used the Entity View Modes (evm) module. I created a custom view mode under Configuration » Entity View Modes » File.

This view mode is now available under Structure » File types » Image » Manage file display

Here I can select the checkbox Image. And then select my desired image style under the Display settings in tab Image select box Image style.

This new view mode is now usable in display suite. If you go to the content type Gallery and click on Manage display where display suite hooks in you can now choose the formatter Rendered file for the field Gallery media. In the formatter settings you'll find your new view mode. Select it and et voilà you get the image with your desired image style.


DS solution

I also found a solution with display suite itself. Without the needing for the additional Entity View Modes module.

Just create a new view mode for File using display suite. Then in the Structure > File types menu you can activate the view mode for Images. And choose your custom image style.

This view mode you can then select in the field template settings like in the description above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.