Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Slider image Cropped (Help required)


Go to End


3 Posts   1271 Views

Avatar
Skullies

Community Member, 19 Posts

13 May 2016 at 6:56pm

Good day
I am trying to get my image slider(Banners) to be cropped by a certain amount.
I have set up my code so in my template it imports :<img src="$Banner.URL" class="img-responsive">
Everywhere i look on the net it shows that i need to use : <img src="$CroppedImage(800,700).URL" class="img-responsive">
and enclose that in a control...
My question is where do i create that control? and is there a easier way to do this?

Thanks
Skullies

Avatar
Optic Blaze

Community Member, 190 Posts

14 May 2016 at 6:45am

Hi Skullies,

There seems to be some inconsistency in your code. In your first example the image source is $Banner.URL and then later you use $CroppedImage.URl, i think what you are looking for is $Banner.CroppedImage(800,700).URL. Have a look at the developer docs for more info. https://docs.silverstripe.org/en/3.1/developer_guides/files/image/#resizing-in-templates

Try that and see if it works

Avatar
Skullies

Community Member, 19 Posts

17 May 2016 at 12:44am

It worked like a charm.

Thanks
~Skullies