Jump to:

23358 Posts in 17875 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » SetWidth works, resize doesn't?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2 3
Go to End
Author Topic: 3974 Views
  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    but should I view the prebuilt image function as unreliable

    No, the prebuilt image function SetWidth, SetHeight, SetSize, CroppedImage all should work pretty well out of the box. You would only need to extend with a custom class if you needed more control over the padding, sizing or other finer details.

    http://doc.silverstripe.org/doku.php?id=image is quite a detailed page. ResizedImage(150,20) is another method you can use in the template (I Believe SetSize() is new so 2.3 may not have it)

  • patjnr
    Avatar
    Community Member
    101 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    Willr can you explain what happened to the ImageEditor which came with the earliest Ver of SS.

    The other way of resizing in templates is by controlling the GD function

    <% control MyImage %>
    <% control SetSize (200,200) %>
    <img src="$URL" alt="My cropped image" />
    <% end_control %>
    <% end_control %>

    The other thing to note when using GD resize functions is some a designed to be used in PHP and some in templates.

    PHP

    $image->resize(width,height);

    Template

    $Image.SetSize(80,80) // returns a 80x80px padded image

    Timtim if you have read Willr's reply, the examples he gave were
    ....the prebuilt image function SetWidth, SetHeight, *SetSize*, CroppedImage ...
    Note he mentioned SetSize and not resize. you can only use resize in PHP.

    http://doc.silverstripe.org/doku.php?id=image *some of the resize functions are meant to be used with the ver 2.4 and they dont work on prior versions*

    Willr please bring back ImageEditor in the CMS

    tx

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    can you explain what happened to the ImageEditor which came with the earliest Ver of SS.

    The original image editor was built by a student for the GSOC program in 2007 and was part of the 2.2 release. But due to javascript upgrades in 2.3 this functionality broke. We contacted the author and as far as I know we could not get a working version setup in time for 2.3 and as time has progressed the functionality has never been fixed.

    I believe the ImageEditor in its 2.2 form won't be reimplemented for 2.4 or future releases, instead it would integrate with picnik.com or another similar online image editing api (or library) from within the cms.

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    Would this also implement the ability to create a manual crop in silverstripe? This is something that I would like to be able to offer my users. Am not sure though if using a commercial third party is a good idea.

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    The licensing of anything we integrate has to be looked at. Using a commercial API is not really an ideal option. The reason for using a third party is because it is such a big piece of functionality and its support / development time that is better spent on other segments of the product.

  • patjnr
    Avatar
    Community Member
    101 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    Yurigoul im with you on manual crop in silverstripe CMS.
    The CMS backend is for the Users not the developers. User must be able to manually crop and resize images in the CMS.
    At time users will upload a 10mb pic into the cms. It will be great to have a form of Editing images in the cms.

    tx

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    I'm using the newest version I downloaded last week (2.3.3) and a fresh install of the current version of MAMP.

    when I tried $HeadShot.ResizedImage(150,20) I get

    <em>
    Website Error
    There has been an error

    The website server has not been able to respond to your request.
    </em>

    and I get nothing in my PHP logs.

    but $HeadShot.SetHeight(150) works fine. I'm a little concerned about this. it's not a huge problem, but I'm in the initial stage of building my first silverstripe page and I don't want to have to second guess things...

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: SetWidth works, resize doesn't? Link to this post

    I do not see that as a function that can be used in your templates. You can use the commands given at http://doc.silverstripe.org/doku.php?id=image in the section about resizing in templates.

    You could however do this:

    <% control MainImage %>
       <% control ResizedImage(260, 120) %>
          <img src="$URL" title="$Top.Title" alt="$Top.Title" />
       <% end_control %>
    <% end_control %>

    or this:

    <% control MainImage %>
       <% control CroppedImage(260, 120) %>
          <img src="$URL" title="$Top.Title" alt="$Top.Title" />
       <% end_control %>
    <% end_control %>

    3974 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.