Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4037896
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:24:20+00:00 2026-05-20T12:24:20+00:00

I am using the Media Plugin (http://www.ohloh.net/p/cakephp-media). I wanna define custom folder for all

  • 0

I am using the Media Plugin (http://www.ohloh.net/p/cakephp-media).

I wanna define custom folder for all the uplaods. i am a little confused where it has to be done.
This is the folder structure i want to achieve

webroot/media/image/original (for the original file storage)
webroot/media/image/large (for the large image filter)
webroot/media/image/medium (for the medium image filter)
webroot/media/image/small (for the small image filter)

also i want to use a random name that i want to generate using the following sript.

//UUID generator
function _imgName() {
    return time() . substr(md5(microtime()), 0, 12);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:24:21+00:00Added an answer on May 20, 2026 at 12:24 pm

    Firstly, having used this plugin, I would recommend considering the default directory structure to keep your app simpler. You don’t want to edit the plugin directly as it will make upgrading more painful…

    # /app/webroot/media/transfer/img/slug.ext (for the original file storage)
    # /app/webroot/media/filter/l/img/slug.ext (for the large image filter)
    # /app/webroot/media/filter/m/img/slug.ext (for the medium image filter)
    # /app/webroot/media/filter/s/img/slug.ext (for the small image filter)
    

    However, the Media plugin configuration file is located at /app/plugins/media/config/core.php and contains some constants that you can override application-wide by defining them in /app/config/bootstrap.php first. To achieve a format somewhat similar to what you want, you could define the following variables:

    define('MEDIA_TRANSFER', WWW_ROOT . 'media' . DS . 'original' . DS);
    define('MEDIA_FILTER', WWW_ROOT . 'media' . DS);
    define('MEDIA_TRANSFER_URL', 'media/original/');
    define('MEDIA_FILTER_URL', 'media/');
    
    # /app/webroot/media/original/img/slug.ext (for the original file storage)
    # /app/webroot/media/l/img/slug.ext (for the large image filter)
    # /app/webroot/media/m/img/slug.ext (for the medium image filter)
    # /app/webroot/media/s/img/slug.ext (for the small image filter)
    

    (Note: you can also set the above paths on a per-model basis by passing the correct configuration options when adding the behavior to your models.)

    You can also redefine the names of the image filters being used to get a step closer to your goal. You need to do this in /app/config/bootstrap.php again, but after you have loaded the Media plugin configuration:

    require APP . 'plugins' . DS . 'media' . DS . 'config' . DS . 'core.php';
    Configure::write('Media.filter.image', array(
        'small' => array('convert' => 'image/png', 'zoomCrop' => array(100, 100)),
        'medium' => array('convert' => 'image/png', 'fitCrop' => array(300, 300)),
        'large' => array('convert' => 'image/png', 'fit' => array(600, 440)),
    ));
    
    # /app/webroot/media/original/img/slug.ext (for the original file storage)
    # /app/webroot/media/large/img/slug.ext (for the large image filter)
    # /app/webroot/media/medium/img/slug.ext (for the medium image filter)
    # /app/webroot/media/small/img/slug.ext (for the small image filter)
    

    If you read the documentation for the Media.TransferBehavior::transferTo() method, you will see you can customize the latter part of the path (ie. img/slug.ext) by reimplementing this method in your model (eg. MyModel::transferTo()). Something like this would get you even closer:

    class MyModel extends AppModel {
        public function transferTo($via, $from) {
            extract($from);
            $mime = Mime_Type::guessName($mimeType ? $mimeType : $file);
            $name = $this->_imgName();
            $path  = $mime . DS . $name
            $path .= !empty($extension) ? '.' . strtolower($extension) : null;
            return $path;
        }
    }
    
    # /app/webroot/media/original/image/129916996632c787226a0b.ext (for the original file storage)
    # /app/webroot/media/large/image/129916998392a3570a1828.ext (for the large image filter)
    # /app/webroot/media/medium/image/12991699891c7625bebedb.ext (for the medium image filter)
    # /app/webroot/media/small/image/12991699938ab22d80cfc6.ext (for the small image filter)
    

    While not exactly what you were looking for (/large/image/ vs /image/large/), this is about as far as you can go without reimplementing larger portions of the plugin. This is because the path is treated as two parts (eg. /media/large/ and image/129916998392a3570a1828.ext) that get appended together later. You can see the append operation happening in the Media.TransferBehavior::_prepare() method and in the Media.GeneratorBehavior::make() method. You would need to either extend the plugin and duplicate those methods (with alterations) in your application code, or hack those two lines directly to get the desired output!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the filterable portfolio script by new media campaigns ( http://www.newmediacampaigns.com/page/a-jquery-plugin-to-create-an-interactive-filterable-portfolio-like-ours ) which
In this movie http://media.railscasts.com/videos/181_include_vs_joins.mov you can see he is using a custom ./script/console and
I'm using a device that's got GPRS media to connect to a PC running
I am using standard 3G connection for video streaming. Streaming Media application works fine.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Am using coda_bubble jquery plugin, and i need to make my bubble pop out
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.