We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32283
    • 17 Posts
    I created a subfolder, went into it, then uploaded an image to that folder. Then I clicked to edit the image, and I saw the cropping/ resizing/ etc controls, but the image is just the "broken image", not the actual image.

    I tried resizing it anyway, and it worked, but obviously there is something wrong. Does anyone know what is wrong?

    Thank you
      • 17134
      • 3 Posts
      Go to "/manager/media/ImageEditor" directory and open "config.inc.php" file. Replace the lines:

      $IMConfig['base_dir'] = $rb_base_dir';

      ->
      $IMConfig['base_dir'] = $base_path.'assets/';

      and
      $IMConfig['base_url'] = $rb_base_url;

      ->
      $IMConfig['base_url'] = $site_url.'assets/';


      :)
        • 32283
        • 17 Posts
        Thanks Liko.

        Just curious, is this a bug in the code that is being fixed in future versions?
          • 4018
          • 1,131 Posts
          A much easier way to fix this would be to simply change a couple of options in the manager. Go to Tools->Configuration and click on the Interface and Features tab. The two options that control where the assets directory is is the Resource Path and Resource URL options. The description of each is pretty self explanatory. Your paths are probably wrong and thus the image is broken in the image editor. Not a bug really...just a few missed settings. smiley
            Jeff Whitfield

            "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
            • 32283
            • 17 Posts
            Thanks for both suggestions. I just want to point out that I think Liko’s suggestion is probably getting closer to solving this for most people, so perhaps a code tweak may be pertinent.

            My reasoning is this:
            The Frame that shows the images for image editing has the following url:
            http://mysite.com/users/test/ctsi/manager/media/ImageEditor/editorFrame.php?img=%2Fimages%2FSunset_1.jpg

            And if I configure the resource url to be: assets/ (which should work, in my opinion), it actually doesn’t work, since the actual php script is deep under the manager/media/ImageEditor/ path, so if I just use "assets", it’s looking for the image under manager/media/ImageEditor/assets (which is not where the assets folder is)

            The fix mentioned by Bravado basically required me to use an initial forward slash in my configuration. I entered /users/test/ctsi/assets/ for the resource url, and it worked fine. But this solution makes it difficult to move the website to another server with a different initial directory structure.

            This issue has to do with general decisions on how to configure MODx.

            In my opinion, path type configuration variables should be figured out relatively by the tool, especially when there is a specific "assets" directory where images are uploaded to by default in the HTML editor. And if they are allowed to be configured, then they should be stored in a config file, not the database. I’ve seen this in other web tools where you move it to a new server, take care of all the settings in the config.php file, then you later discover that some settings are stored in the database, but you have difficulty going into the admin part of the tool to change it because it’s using the settings already. This wouldn’t happen here, since it’s just broken images, but I hope you see my point.

            The suggestion to tweak the image editor’s config file I believe is the proper one, as it uses already known config variables ($base_path and $site_url) and just appends them with "assets", which is the well known place for the images. I’m not so sure hard coding to "assets" is right, but the idea of starting with the known variables and appending another folder is the idea I like.

            I’m open to comments! Thanks for reading.
              • 4018
              • 1,131 Posts
              Only problem with that is that if you decide to use a different directory other than assets to store your image files and such then you have to go back and change the path in the config file...which in my humble opinion isn’t the ideal. I’m not big on hardcoding any paths like that.

              Changing the config for the resource path and URL is easier even if you’re moving a site from one URL to the next because you only have to change the setting in one place and don’t have to dig around a config file. I’ve moved plenty of sites from one URL to the next and find it to be quite easy. The trick in knowing that you will have to change a few configuration options here and there with the correct paths. About the only files I ever have to touch is the main config.inc.php file and a few files in the cache directory.
                Jeff Whitfield

                "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
                • 32283
                • 17 Posts
                I don’t like hardcoding either, which is why I said:
                I’m not so sure hard coding to "assets" is right, but the idea of starting with the known variables and appending another folder is the idea I like.

                So my proposal, then, simply is to have the image manager’s configuration as such:
                $IMConfig[’base_dir’] = $base_path.’/’.$rb_base_dir;

                and
                $IMConfig[’base_url’] = $site_url.’/’.$rb_base_url;

                or something like that, so that someone who doesn’t have their MODx installed at the root, can easily move the installation to a site that is under the root, without changing their configuration.

                Now, if I’m currently installed under: http://mysite.com/mytestmodx
                my resource url would have to be: /mytestmodx/assets

                and have to change to just /assets when I moved the site.

                However, with this modification, it could just be "assets", and it would work even after moving it to a different directory structure.

                Hope this makes sense... directory path configuration is always difficult when a web application uses third party things like editors and image managers, but I think it’s worth it to explore changing this behavior...
                  • 4018
                  • 1,131 Posts
                  Have to admit...that’s a good compromise. Probably will need to make sure that this kind of change is well documented and emphasizes the way it works. Else, we’ll have plenty of pissed off MODx users wondering why stuff is getting broken with this. smiley

                  I’ll put it on my to-do list of things to explore and implement. No doubt, this is a good idea. laugh

                  Jeff
                    Jeff Whitfield

                    "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."