We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40232
    • 2 Posts
    Hello, I'm newbie in MODX and I'm want to know if is it possible to import html files with linked png images into my MODX site?
    When I import the html files, png images are ignored, and the images appear broken in the imported html page.

    I'm using MODX Revolution 2.2.4 in a Debian Squeeze server.
    Thanks in advance
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      Make sure the path is correct in your html file, it will have to be an absolute path to work if the images are hosted on another server.
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 40232
        • 2 Posts
        Hi Frogabog, thanks for answer.

        The images aren't in another server, and the path point to images in the same folder as html files, i.e: <img src="image.png" />

        I think that I could make a directory tree in the modx folder to upload the images and then fix the paths in the resources, but I prefer an automatic task (to avoid human errors).
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          Where is MODX installed? Is it in a subdirectory of the folder with the html files and images or have you installed it in the folder where the images reside? If in a subfolder, you'll have to use something like ../imageName.png because a relative path like you're describing would look in the folder that MODX is installed on.

          It's actually best to store images in the assets folder, either under templates/yourTemplate/images or in assets itself and then call images with an "assets/images/imageName.png" path.

          You can make a special placeholder setting like
          [[++images]]
          then set that path absolutely in the settings, so that whenever you want to call images you'll be able to use the placeholder tag you created plus the image name.

          i.e.
          <img src="[[++images]]imageName.png" />
          [ed. note: frogabog last edited this post 14 years, 4 months ago.]
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 3749
            • 24,544 Posts
            MODX assumes that all paths that are not full URLs are relative to the MODX site root. That's why it's not finding the images.

            Frogabog's method is the correct one, although you could skip creating the setting and just use something like this:


            <img src="[[++assets_url]]images/imageName.png" />


            You could also create a plugin connected to OnWebPagePrerender that would rewrite all the image tags to point to the correct location, though it would slow page loads a little.

            If you want to cheat, though, and don't mind having the images cluttering up the site root, I think that if you copy all the images to the MODX site root, what you're doing now would work.



            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html




              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 10208 ☆ A M B ☆
              • 1,780 Posts
              Good points Bob. Simpler overall.

              The only real benefit of the images url set in the placeholder would be that the images could actually remain where they are now. Copying images to another folder would be my choice however.
                Frogabog- MODX Websites in Portland Oregon
                "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                Having server issues? These guys have MODX Hosting perfected - SkyToaster
                • 3749
                • 24,544 Posts
                Frogabog, the big advantage to your method would be that you could move the images whenever you felt the need and just change the System Setting. It's really a much more robust solution than either of mine. I just mentioned them as options because the idea of messing with System Settings makes some users uncomfortable.

                It seems like there should be a way to get a Media Source involved in this, but the docs on Media Sources are a little sketchy.


                ------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using.
                MODX info for everyone: http://bobsguides.com/modx.html
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting