0

On drupal 7 I created two new image styles. Now when I save new contents, I expect the new images to be saved in the new image styles as well but this does not happen. Images are only saved in the ordinary thumbnail, medium, large and square-thumbnail sizes.

How can I make the new image styles be honored?

Edit: So Mołot and Bala made it clear that a certain image style has to be called to generate an image of that style. Yet, I would like to call for a smaller image in the code, and then load a larger version for wider screens.

Is this possible? Note: I am using ZEN as the theme.

Edit 2:

What I want to do is to load an initial small image like:

<img class="resp-image" src="very-small.jpg" />

Then, according to the screen size, I will replace the image with a larger version. This version of the image is provided by an image style:

if($(window).width() > 768) { 
    $('.resp-image').attr('src', 'large.jpg');
});

The problem is, since I do not refer to large.jpg in the content type's display settings, it is not rendered to the given style and thus does not exist yet.

I was going to put this up as a new question but I found out that it is already discussed here and here.

Mołot's answer best described the situation referred to in the inital question. So I accepted it.

7
  • go to manage display and set the style you want under the format
    – Bala
    Sep 9, 2013 at 11:43
  • yes, that solves the issue... almost. I am using a mobile first way to develop and was hoping to swap the larger image (the new style) with the smaller one. So drupal will know it to be the smaller image, which takes me back to the beginning.
    – turzifer
    Sep 9, 2013 at 11:47
  • Do you know how Zen uses and replaces images?
    – Mołot
    Sep 9, 2013 at 12:18
  • where do you going to place the small image, in teaser ?
    – Bala
    Sep 9, 2013 at 13:26
  • to add image in your code follow this drupal.stackexchange.com/questions/83767/…
    – Bala
    Sep 9, 2013 at 13:32

2 Answers 2

1

Images are only rendered to a given style when something actually tries to use that style. If you want to force generation, you need to use image_style_url to obtain URL for the image, and then download it via regular HTTP request. It becomes more complicated if you don't want to download (aka show) it. In that case, use image_style_deliver.

2
  • Thank you @Mołot. I edited my question in the light of the information you gave. I checked the function names you mentioned but could not figure out how to use them. Do I need to edit some modules' code or is there a way to use it via the admin interface?
    – turzifer
    Sep 9, 2013 at 12:17
  • Usually it's either a field setting as Bala shown you, or you call this functions in .tpl file you want to display image in. I don't quite know how Zen is doing it.
    – Mołot
    Sep 9, 2013 at 12:20
1

Go to manage display and set the style you want under the format, see the below screenshot and choose the image style you created. enter image description here

Your Answer

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

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