Skip to content
Grav 2.0 is officially stable. Read the announcement →
Plugins

Crop images from a carousel

first-time plugins

Started by kouhafa 5 years ago · 5 replies · 974 views
5 years ago

hello mates,

I would like to crop the images of my carousel but I don't know how to do it, I'm a beginner on grav.

I would also like my carousel not to take the whole width of my page, how should I proceed?
I use Shortcode Owl Carousel Plugin.

below is an image of my current carousel and my code

HTML

[owl-carousel items=1 margin=10 loop=true autoplay=true autoplayHoverPause=true nav=true]
<div style="background: url({{ page.media['inscription.png'].url }}) 50% 50%;background-size: cover;color:#fff;">
  <h2>This is panel 1</h2>
  <p>foo</p>
</div>
<div style="background: url({{ page.media['identification.png'].url }}) 50% 50%;background-size: cover;color:#fff;">
  <h2>This is panel 2</h2>
  <p>foo</p>
</div>
<div style="background: url({{ page.media['photocaution.png'].url }}) 50% 50%;background-size: cover;color:#fff;">
  <h2>This is panel 3</h2>
  <p>foo</p>
</div>
[/owl-carousel]```

![Capture d’écran 2021-07-20 à 11.24.44|690x119](upload://7DyNv0LALQyOs4BhxhfLApRlZYV.jpeg)
5 years ago

Did you check the Media docs?
It would be something like:

TWIG
{{ page.media['identification.png'].cropResize(200, 200).url }}
5 years ago

Yes but it doesn't work.
Maybe if i narrow the width of the carousel it would work, where do I have to make changes for this ?

5 years ago

What do you mean it doesn't work? What's the result now and what do you expect? Remember you have a background-size: cover, so visually there shouldn't be much difference (if at all, depending on original image size)

As for the width, I would guess it's a theme thing and you need to extend it and adjust template and/or CSS, but without more info, again, it's just a guess

5 years ago

Here is what I have

Capture d’écran 2021-07-20 à 12.27.41|690x319

I want a more centered and less wide carousel so that the images appear properly

5 years ago

It looks like a pure CSS issue, but without seeing HTML and CSS not much we can advise

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 80 1 week ago
Plugins · by Xavier, 4 weeks ago
2 84 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1210 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 77 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 104 2 months ago