ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to insert resized image to content with File Manager?

October 06, 2012 4:26pm

Subscribe [1]
  • #1 / Oct 06, 2012 4:26pm

    PXBob

    2 posts

    My client wants to add images straight to content. We did them a new “Content” -image destination folder and resize options to make sure they use correct size images. However it seems that it’s impossible to use these resized images in content(textareas) with File Manager?

    Have I missed something or how can this be true? Anyone knows any nice and minimal addon to handle this?

    I’ve even tried with Assets and Wygwam but not possible at least with basic options.. and that CKEditors Image insert has so clutterish look that I wish I dont have to use it because of this.

    I checked source code of File Manager but “problem” is that code relies too much to db file id:s. I hoped that File Manager would have just passed directory and filename to texteditor but it’s file id that it is using. There’s basically two options that came to my mind.. to write resized images to db OR change File Manager js script to pass directory and file name to txt editor. And with PHP read selected directory subdirectories and look for files with same name and if found -> set those as options beneath original filename with subdir name like url/basicimage/_content/filename.jpg .

  • #2 / Oct 07, 2012 3:14pm

    PXBob

    2 posts

    Here’s two ways I found to do this:

    With built in File Manager (normal/rte):

    1. Create upload directory and name it “basic” (url: http://example.com/images/uploads/basic)

    2. Create Image Manipulation method for this Filetype/Upload directory and name it for example “small”.

    3. Create another upload directory and name it “basic small” and set paths to subfolder of folder we created at part 1. (http://example.com/images/uploads/basic/_small)

    4. Now upload image. If you check File Manager you can see there’s too dirs now: basic and basic small. Basic small is however empty. There are manipulated images inside folder but those haven’t been added to database.

    5. To add these to db go to File Upload Preferences where you can see both preferences: basic and basic small. On right side there’s Synchronize column. Click icon on “basic small” row and all the images in current dir will be added to database.

    6. If you now open the File Manager from texteditor, you will see resized images in that “basic small” directory and you can use them in content just like original images.

    With Wygwam/Assets this is bit easier, but costly method if you need Assets only for this:

    1. First change from Wygwam settings File Manager to Assets.

    2. Do same as above but there’s no need to synchronize. So skip part 5.

    3. Open assets from textarea and you see now both folder and original and resized images.

    Conclusion:

    Both ways seem to work ok though in my opinion feature like this should come out-of-the box by choosing wanted version of image in File Manager.

    Both file managers uses main directories created in File Upload Preferences. Built in File Manager displays images thru database but assets seems to read files from directory. But not subdirectories. I think CKFinder and TinyMCE filebrowsers would read all directories but I didn’t get CKFinder to work and I’m not fan of either so I don’t mind.

    I was thinking would it be possible to create extension and use file_after_save -hook and synchronize this Upload destination for resized images automatically after file upload.. ? I’ll start looking this closer next week but if you have any thoughts I would appreciate and maybe save some time.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases