We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49499
    • 48 Posts
    I have an image field in MIGXdb that uses a media source with the ID 17. The field works perfectly in the manager, but just outputs the filename (without the full URL) in the "web" context. Does anyone have any suggestions?

    Thanks in advance!

    Here is my configuration for that field:
    {
              "MIGX_id":210,
              "field":"image",
              "caption":"Image",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"image",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":[
                {
                  "MIGX_id":1,
                  "context":"web",
                  "sourceid":17
                },
                {
                  "MIGX_id":2,
                  "context":"mgr",
                  "sourceid":17
                }
              ],
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":7
            },


    My call:
    [[migxLoopCollection?
    	&classname=`Endorsement`
    	&packageName=`endorsements`
    	&prefix=`modx_custom_`
    	&tpl=`tpl.Endorsement`
    	&where=`{"published":"1"}`
    	&sortConfig=`[{"sortby":"pos","sortdir":"ASC"}]`
    ]]


    My tpl:
    <li>
    	<article class="c-endorsement">
    		<div class="c-endorsement__image">
    			<img src="[[+image]]" alt="[[+name]]" />
    		</div>
    		<header class="c-endorsement__header">
    			<h5 class="c-endorsement__name">[[+name]]</h5>
    			<p class="c-endorsement__meta">[[+location]]</p>
    		</header>
    		<div class="c-endorsement__text">[[+endorsement]]</div>
    	</article>
    </li>
      • 4172
      • 5,888 Posts
      migxLoopCollection doesn't know about the used mediasource.

      But you can create a snippet 'add_mediasourcepath':

      $output = str_replace('./','',$input);
      if ($mediasource = $modx->getObject('sources.modMediaSource',$options)){
          $output = $mediasource->prepareOutputUrl($output);
      }
      return '/' . $output;
      


      and use it as an output-filter:

      [[+image:add_mediasourcepath=`17`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!