We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48380
    • 4 Posts
    Hello! I've searched for the solution on this forum and google but I didn't find anything, so I could do nothing but ask for help:
    I want to assing custom media source for MIGX image field. I use MIGX configurator, here is the schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <model package="popularservices" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    	<object class="Popularservices" table="popularservices" extends="xPDOSimpleObject">
    		<field key="resource" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
    		<field key="image" dbtype="mediumtext" phptype="string" null="false" />
    		<field key="rank" dbtype="int" precision="11" phptype="integer" null="false" />
    	</object>
    </model>
    


    And here is the JSON config:
    {
      "formtabs":[
        {
          "MIGX_id":2,
          "caption":"\u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0443\u0441\u043b\u0443\u0433\u0438",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":5,
              "field":"resource",
              "caption":"resource",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"resourcelist",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "pos":1
            },
            {
              "MIGX_id":7,
              "field":"image",
              "caption":"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435",
              "description":"",
              "description_is_code":"0",
              "inputTV":"service_image",
              "inputTVtype":"",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"tv",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "pos":2
            }
          ],
          "pos":1
        }
      ],
      "contextmenus":"update||remove",
      "actionbuttons":"addItem",
      "columnbuttons":"",
      "filters":"",
      "extended":{
        "migx_add":"",
        "disable_add_item":"",
        "formcaption":"popularservices",
        "update_win_title":"",
        "win_id":"popularservices",
        "maxRecords":"",
        "addNewItemAt":"bottom",
        "multiple_formtabs":"",
        "actionbuttonsperrow":4,
        "winbuttonslist":"",
        "extrahandlers":"",
        "filtersperrow":4,
        "packageName":"popularservices",
        "classname":"Popularservices",
        "task":"",
        "getlistsort":"",
        "getlistsortdir":"",
        "sortconfig":"",
        "gridpagesize":"",
        "use_custom_prefix":"0",
        "prefix":"",
        "grid":"",
        "gridload_mode":1,
        "check_resid":1,
        "check_resid_TV":"",
        "join_alias":"",
        "has_jointable":"yes",
        "getlistwhere":"",
        "joins":"",
        "cmpmaincaption":"",
        "cmptabcaption":"",
        "cmptabdescription":"",
        "cmptabcontroller":"",
        "winbuttons":"",
        "onsubmitsuccess":"",
        "submitparams":""
      },
      "columns":[
        {
          "MIGX_id":3,
          "header":"id",
          "dataIndex":"id",
          "width":"",
          "sortable":"false",
          "show_in_grid":"0",
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        },
        {
          "MIGX_id":2,
          "header":"\u0423\u0441\u043b\u0443\u0433\u0430 (\u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0435\u0441\u0443\u0440\u0441)",
          "dataIndex":"resource",
          "width":"",
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"this.renderChunk",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"[[#[[+resource]].pagetitle]] ([[+resource]])",
          "renderoptions":""
        },
        {
          "MIGX_id":4,
          "header":"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435",
          "dataIndex":"image",
          "width":"",
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"this.renderImage",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        }
      ]
    }
    


    The media source path and url are both "assets/content/services-images/", relative path and url are on.
    I use CMP to manage the records, and they are saved properly in the DB table. When I go to my CMP and press "Add item" and choose the image, it starts with the correct folder, "assets/content/services-images/". But when I click save, it doesn't show the thumbnail in the grid. The image src as Firebug shows is: "/connectors/system/phpthumb.php?h=60&src=./164673_0.1364489472.jpg&source=1". Just in case, I've set all files and folders permission to 777 for the test. MODX version is 2.3.1, and 2.2.15 (I've tried both of them), and MIGX version is 2.8.1.
      • 4172
      • 5,888 Posts
      The file-browser does add ./ before the filename, when you are in the root of the mediasource's path.

      I think, it is an file-browser issue somehow.

      As an workaround, you can create a customized copy of the default update-processor and remove it with str_replace, before saving to the db.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 48380
        • 4 Posts
        Again that happened: 3 hours of searching for the solution, and 20 minutes after I've decided to ask on the forum, I've found a way: We use this.renderChunk instead of this.renderImage for the image, and renderChunk template is:
        <img src="/connectors/system/phpthumb.php?w=100&src=[[+image]]&source=2" alt="">

        &source is the id of media source. Here it works fine, and the problem is solved, but still the question is, can I setup renderImage to work properly? Is this a bug or I'm missing something?
          • 48380
          • 4 Posts
          Quote from: Bruno17 at Oct 04, 2014, 11:48 AM
          The file-browser does add ./ before the filename, when you are in the root of the mediasource's path.

          I think, it is an file-browser issue somehow.

          As an workaround, you can create a customized copy of the default update-processor and remove it with str_replace, before saving to the db.
          Thank you for so quick reply!
          With the Firebug, I also noticed, that generated image src in the grid column sets &source=1 (default mediasource) in the call to phpthumb (<img src="/connectors/system/phpthumb.php?w=100&src=01.png&source=1" alt="">. Maybe, there is a way to setup column renderer to take custom mediasource ? This is a "by-the-way" question, just if there is an intended/official way to do it, the major thing is that it works fine without any nasty hacks / workarounds smiley [ed. note: jdwebl last edited this post 12 years ago.]
            • 4172
            • 5,888 Posts
            not sure, if this would help, but you can try to set the sourceFrom to 'config'

            and add two sources - items
            one for the context web
            and one the context mgr
            each with your mediasource-id

            in the MIGX-mediasources - configuration for that field
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!