We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13218
    • 134 Posts
    I'm using Image+ with a media source that uses migxResourceMediaPath for dynamic folders.
    Media source has the template:
    /assets/images/resource/{id}/


    Works fine when I'm displaying the image on the resource, where it is actually uploaded (e.g. with id 1).
    But when I try to call that image (the image+ tv) from another resource (e.g. id 2), then of course the images src reads
    /assets/images/resource/2/image.jpg
    instead if id 1, therefore the image is not found.

    I have tried setting option 'docid' to 1, also setPlaceholder('docid',1) before calling the snippet.

    Is there a way to make that work, meaning to set the correct resource id?
      @itWilllBeOK
      • 4172
      • 5,888 Posts
      what is your snippet-call and your tpl-chunk?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 13218
        • 134 Posts
        I've tried to keep it simple.

        $src = $modx->runSnippet('imageplus', array(
            'docid' => 1,
            'tvname' => 'seo-image',
            'options' => 'w=1200&aoe=1'
        ));

        and
        [[ImagePlus?
            &tvname=`seo-image`
            &docid=`3`
            &options=`w=450`
        ]]

        which in both cases return on resource 1 (the one with the image):
        /assets/image-cache/cat.23e1c966.jpg


        On resource 2 (also calling docid 1) both return (notice the 2 as docid in the path):
        /var/www/xxx/public/assets/images/resource/2/cat.jpg
          @itWilllBeOK
        • Is the dynamic base path a MIGX enhancement or does that work outside of MIGX?

          In both crop engine classes the path of the media source is generated by
          $imgPath = $source->getBasePath() . $data->sourceImg->src;


          I think Bruno should rewrite https://github.com/Bruno17/MIGX/blob/master/core/components/migx/elements/snippets/migxresourcemediapath.snippet.php to a MODX service class and make it callable from outside.

          Or the migxresourcemediapath code has to be implemented in Image+ snippet and tv output. [ed. note: Jako last edited this post 8 years, 8 months ago.]
            • 13218
            • 134 Posts
            It's a migxResourceMediaPath, which works outside of MIGX if you're saying that a TV using it with a media source is outside of MIGX.

            Basically a media source with paths set like:
            [[migxResourceMediaPath? &pathTpl=`assets/images/resource/{id}/` &createFolder=`1`]]


            Setup like this:
            https://rtfm.modx.com/extras/revo/migx/migx.tutorials/migx.use-resource-specific-media-source-and-multifile-uploader
              @itWilllBeOK
              • 4172
              • 5,888 Posts
              $docid = '1';
              $modx->setPlaceholder('docid',$docid);
              $src = $modx->runSnippet('imageplus', array(
                  'docid' => $docid,
                  'tvname' => 'seo-image',
                  'options' => 'w=1200&aoe=1'
              ));


              doesn't work?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 13218
                • 134 Posts
                Tried that, won't work.
                  @itWilllBeOK
                  • 13218
                  • 134 Posts
                  Ok, so Jako say: "Not possible without patching image+".
                  So there's that.

                  Here's to patching!
                    @itWilllBeOK