MIGX

Specifying the Media Source for a MIGX TV

hearty fare

MIGX Media Source

One of the snippets that comes with the MIGX package is migxResourceMediaPath. This snippet can be used to create dynamic paths to images and other files according to the resource they are associated with. Then you need to tell MIGX to use that Media Source for its images.

designcouch asked...

I'm using MIGX to power an image gallery for a new site, and I would like to specify a media source for it to use. I've tried creating a media source with a base href and base url that look like this:

    [[migxResourceMediaPath? &pathTpl=`assets/images/gallery_images/{id}/`]]
  

and then assigning that media source to my MIGX tv. The issue is, no matter what I do, the file browser still shows the root folder instead (what it would do if no custom media source was specified).

The Solution:

Bruno17 says...

There are several ways how you can assign a mediasource to a MIGX-image.

If you are configure the MIGX-TV directly in the formtabs of the MIGX-TV-input-options, you may have either

    "inputTV":"anyImageTv"
  

than you will need to have a image-TV with name 'anyImageTv' (no template assigned) and assign the mediasource to that TV

or...

you can do it this way:

    [{"caption":"test"},{"fields":[
{"field":"image","caption":"Image","inputTVtype":"image","sourceFrom":"migx"},
{"field":"image2","caption":"Image","inputTVtype":"image","sourceFrom":"config","sources":"[{\"MIGX_id\":\"1\",\"context\":\"web\",\"sourceid\":\"3\"},{\"MIGX_id\":\"2\",\"context\":\"de\",\"sourceid\":\"3\"}]"},
{"field":"test2","caption":"test2"}]}]
  

the first image-field has its source from the migx-TV, the second image-field has its source from its own configuration under the sources-config.

Or you can do all that from the MIGX-configuation-CMP without messing arround with json-strings

What's the Story?

The snippet can be used as the path and the URL for a Media Source. It will use the resource ID as a folder name to have a folder for the images for each resource. You can specify the Media Source to use for the MIGX TV in several ways, as Bruno17 specified. In most cases, the easiest way is to define the image field as an inputTVtype of image, specify the sourceFrom as migx, and assign the whole MIGX TV to that Media Source.

  {"field":"image","caption":"Image","inputTVtype":"image","sourceFrom":"migx"},