We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49320
    • 1 Posts
    I have been charged with the rather large task of writing SEO descriptions and alt text for all images on our site. I have relatively elementary knowledge of the reporting capabilities of Modx. I am wondering if there is a way that I can get a nice report that lists all the images on the site with info like image name and URL, etc? We are on Modx Revo 2.2.4. Or, are there any tools/plugins that you may be aware of that would streamline the process?

    Thanks in advance for your help!
      • 3749
      • 24,544 Posts
      I don't know of anything that does that. If the developer has been thoughtful enough to put all the images in the assets/images folder, you could look there, but you wouldn't know if you had all the images.

      The only ways I can think of to reliably find all the images would be to

      1. Get every page at the site with cURL and scrape it looking for image tags. That would give you each image's URL, and existing alt tag, if any.

      2. Recursively walk the directory tree of MODX files looking for image files (.jpg, png, etc.). That would give you the filename and you could calculate the URL but you wouldn't know of any existing alt tags and you might miss some images. You'd want to skip the manager/ folder, which has many images that are used only in the Manager.

      I would do number one. It would run much slower, but it would be more reliable, have more straightforward code, ignore Manager images, and give you more information.

      That would look something like this:


      $docIds = $modx->getChildIds(0);
      foreach($docIds as $docId) {
          $url = $modx->makeUrl($docId, "", "", "full");
        
          /* Get page here with cURL */
         
          /* Get Page base href with preg_match */
      
          /* Get image tag data with preg_match_all */
      
          /* add data to $output */
      
      }
      
      return $output;
      



      If you have more than one front-end context, you'd need to do the loop above for each one.
        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