Add resource-specific mediasource and multifile-uploader to the gallery
Last updated Dec 8th, 2019 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$301 per month—let's make that $500!
Learn moreCreate the dynamic resource-specific media source¶
- Go to: Media->Media Sources
- Create new media source
- name: ResourceMediaPath
- source type: Filesystem
- Update this media source
- basepath and baseurl:
[[migxResourceMediaPath? &pathTpl=
assets/mygallery/{id}/&createFolder=
1]]
- basepath and baseurl:
You may also need to create a directory with write-permissions for php: assets/mygallery/
Assign the media source to the image-field¶
- Go to: Extras->MIGX
- Edit your Config (right-click the config-item in the grid)
- Go to the Tab 'Formtabs' -> Edit the Formtab 'Image' -> Edit the field 'Image' 3.1. At the Tab 'Mediasources' add two new Items for the contexts 'web' and 'mgr' with the newly created mediasource-id
Modify your tpl¶
Create a snippet with name 'addmediasourcepath' with this code:
$output = str_replace('./','',$input);
if ($mediasource = $modx->getObject('sources.modMediaSource',$options)){
$output = $mediasource->prepareOutputUrl($output);
}
return '/' . $output;
In your tpl change the image-placeholder to something like that:
[[+image:addmediasourcepath=`3`]]
In case, you are using pthumb for image-resizing, to something like that:
[[+image:addmediasourcepath=`3`:pthumb=`w=500`]]
Change the mediasource - id, in the example above '3' to yours!
Add Upload-Button¶
- Go to: Extras->MIGX
- Edit your Config (right-click the config-item in the grid)
- At 'Mediasource ID' put the id of your mediasource
- At Tab 'Actionbuttons' select 'uploadfiles_db' and remove the selection 'addItem'
- Save everything
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$301 per month—let's make that $500!
Learn more