Path configuration in media gallery module
The solution that Letharion posted will work fine, but making integration with path auto is a better solution like (s)he writes.

Doing this in not that hard, but it can be a bit tricky to do the first time.

To do it you need a few steps.


First you need to implement hook_pathauto in order to get the setting for how the alias should look like. Here you can give info about which type of token can be used for path replacements etc.
Second you need to create a function which can be used to generate an alias. It should look something like this.

function foo_pathauto_update_alias($file, $op, array $options = array()) {
  module_load_include('inc', 'pathauto');
  $path = media-gallery/detail/' . $file-&gt;bid . '/' . $file-&gt;fid
  pathauto_create_alias('aug_product', $op, $path, array('file' =&gt; $file));
}


Path auto is based on entities. So you need to be able to generate the path from a single entity. In this case the file that's created. By using the above function structure you can use a single function and utilize it for bulk updates as well as regular updates while keeping path auto functionality intact.
Lastly you need to call your update function when file is created or updated. This will handle path alias creation. Doing it this way, you can also get path auto to update path alias if the data is changed and the alias should be different, if you want to do so. There is settings for this in the path auto module.
For bonus you can choose to create a bulk update function, that will enable you to the alias for any file created. It takes a bit of work, but should work nicely.


Note doing it this way, it will be a good idea to use the file entity module, as it allows you to handle files like entities, which fits path auto a lot.