21298 Posts in 5735 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 2579 Views |
-
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

27 July 2012 at 9:50pm
works fine in my test.
check your image size and maybe add some print functions in the controller function to check. -
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

28 July 2012 at 2:32am
The issue is that I'm calling the function within the scope of Images that I've setup with a many_many because of the SS bug.
-
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

28 July 2012 at 3:07am
Maybe use SS 3.0.1 RC2
-
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

28 July 2012 at 5:11am
I don't think it was fixed in that RC according to the change log.
It's more of a scope issue. I don't know how to call the function within the Image loop. I've tried $Top in some places, but so far nothing.
-
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

28 July 2012 at 10:58pm
if you are in the loop, use $Up to move one level up in the scope. Which should make something like <% if $Up.greaterThan($Width, 800) %>
all the answers are here http://doc.silverstripe.org/framework/en/reference/templates -
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

29 July 2012 at 7:54am
I had originally tried that with $Top and no luck. Same goes for $Up.
If I use your function outside of the Images loop it returns correctly
See anything wrong with this:
public function greaterThan($value, $reference) {
if ($value > $reference){
return true;
}
else{
return false;
}
}<% loop Images %>
<% if $Up.greaterThan($Width, 800) %>
<a href="$SetWidth(800).URL" class="itemPhotos <% if MultipleOf(5) %> itemPhotosLast <% end_if %>" title="$Title">$CroppedImage(158,158)</a>
<% else %>
$Width
<% end_if %>
<% end_loop %>I'm just putting $Width in the else block to see how it returns. It always returns false and I have images both smaller and larger than 800. I've tried $Up, $Top and at the front and end of the function just to test. Nothing works. Always false.
-
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

30 July 2012 at 10:52pm
$Up seems to work fine on my setup.
can you attached your files, Model, Controller and Template? -
Re: [SOLVED] SS3 Upload many files/images [SOLVED] Resize image if it's larger than a certain width

2 August 2012 at 8:17am
Here is the php - http://pastebin.com/g0dMJL0w
Here is the template - http://pastebin.com/nH4N6uu4
| 2579 Views | ||
| Go to Top | Next > |



