On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hello, I'm trying to make a nested MigX that load images but with the custom Media Source that I'm using by default.

    1. I'm not using MigX DB
    2. I'm building the strucures inside the MigX manager using formtabs and columns
    3. A normal MigX not nested works perfectly fine with the Custom Media Source
    4. The nested images path is working right if the Image mediasource is the default one:
    mgr 1
    web 1
    

    But if I try to use the Custom Media Sourse called: WebFiles ID 2 (the path is not right):
    eg:

    path with mediasource: mgr 1 - web 1
    assets/web/user_files/image.jpg

    path with custom mediasource: mgr 2 - web 2
    image.jpg

    I can add the path manually but that is not the right way and I'm using pthumb to set the image size:
    [[+image:pthumb=`w=280&h=210&q=60&zc=1`]]

    I tried everything but no luck, no idea what else can I do, any help please?

    Here the Custom Media Sourse: WebFiles ID 2

    basePath
    Textfield
    assets/web/user_files/
     
    basePathRelative
    Yes/No
    Yes
     
    baseUrl
    Textfield
    assets/web/user_files/
     
    baseUrlRelative
    Yes/No
    Yes
     
    allowedFileTypes
    Textfield
     
     
    imageExtensions
    Textfield
    jpg,jpeg,png,gif
     
    thumbnailType
    List
    PNG
     
    thumbnailQuality
    Textfield
    75
     
    skipFiles
    Textfield
    .svn,.git,_notes,nbproject,.idea,.DS_Store



    Apart of that, everything is working well, the nested MigX is showing images and everyhting looks good.
    The custom Media Source is because I don't want some users have access to rood files obviously.

    Thank you very much, cheers!

    This question has been answered by Bruno17. See the first response.

      --
      ysanmiguel.com
    • discuss.answer
      you can try this output-filter (snippet with name 'add_mediasourcepath'):

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


      use it like that:

      [[+image:add_mediasourcepath=`2`:pthumb=`w=280&h=210&q=60&zc=1`]]




        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • Bruno, Thank you very much!
        Excellent, it's working perfect.

        Cheers!
          --
          ysanmiguel.com
        • When I use `add_mediasourcepath` snippet, I have an error

          Parse error: syntax error, unexpected '$output' (T_VARIABLE) in /home/www/core/cache/includes/elements/modsnippet/31.include.cache.php on line 4
          • could you copy/paste your snippet-code here, please.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!