Jump to content

Auto-resizing images within Tiny MCE editor


almonk
 Share

Recommended Posts

Hi guys

At the moment I'm building a site for a client that include a blog which will be functionally similar to a tumblog.

Thanks to Processwire's built in Image plugin for Tiny MCE, we get a nice interface for resizing images that are too big - however, I'm looking for a way to resize the images automatically once placed in the Tiny MCE editor to be the correct size.

One solution I tried to implement myself was creating an extra 'Autosize Image' button in the image picker dialog that would instantly resize to a given width but I didn't get very far as my Tiny MCE foo is clearly lacking.

Any ideas on how to approach this?

Al

Link to comment
Share on other sites

One idea is that we could add an optional max width/height specification to the FieldtypeImage field, so that it would downsize any particularly large images automatically at upload time. In that manner, you could specify the max size for your needs in TinyMCE. Another possibility is that we could make this setting part of the InputfieldTinyMCE, where it checks the max size at the time you click an image to paste it in... if the image is larger than the max, it resizes it before completing the paste. I'm not sure that either solution is necessarily a quick n' easy approach, but it does seem that something like this is necessary. I guess the question is whether it should be part of the FieldtypeImage, which would extend it's use outside of just TinyMCE; or whether it should be specific to TinyMCE. 

Link to comment
Share on other sites

Personally, I think it makes sense that the height/width are set as optional defaults on the field (rather than anything to do with Tiny MCE). This seems to make more sense to me than introducing more complexity into Tiny MCE.

I might have a stab at this later, although I think module development might be slightly more than my php skills can tackle ;)

Link to comment
Share on other sites

In PW 2.1, the latest commit supports specifying max width and/or height dimensions for any field using InputfieldImage (which is what's used by FieldtypeImage). You'll see these in the settings for your image(s) field.

Thanks,

Ryan

Link to comment
Share on other sites

This is great news! I had training session for our client how to use processwire and there were 14 people listening. This was one of the first questions there, so great that there is a solution ready.

I have some other good points from client, but I put those on other topic.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...