We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    I have a new one for you : is it possible to display the image size in MaxiGallery templates (namely, the gallerypicturetpl template) ?

    I didn’t find any placeholder to that purpose... I thought of using the FileDetails snippet but then again I can’t put a snippet call in a maxigallery undecided

    Would it be possible to include the filedetails.inc.php in maxigallery :

    return include($modx->config[’base_path’] . ’assets/snippets/filedetails/filedetails.inc.php’);

    And then use the FileDetails placeholders in MaxiGallery templates ?

      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 10449
      • 956 Posts
      Filesize (KB, MB) or dimensions (width/height)?

      I guess you’d have to change maxigallery.php around line 752 to add filesize infos:
      			$pictureTplData['picture_height_big'] = $imagesize[1];
      			$pictureTplData['picture_width_big'] = $imagesize[0];
      
      


      Otherwise, you could probably just use those vars ^
      or... use the third array-index, that already produces the width= height= HTML string
      $pictureTplData[’picture_wh’] = $imagesize[3];


      You’d have to add the new placeholder in picturetpl.html, e.g.

      <img src="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]" [+maxigallery.picture.wh+] class="imageview" alt="[+maxigallery.strings.date+] : [+maxigallery.picture.date+]" />


      disclaimer: not tested smiley
        • 10449
        • 956 Posts
        for filesize, maybe this could work:

        $pictureTplData[’picture_filesize’] = size_readable(filesize($modx->config[’base_path’].$mg->path_to_gal."big_".$pics[$i][’filename’]));
        (somewhere after line 752)

        the size_readable function is here: http://ch2.php.net/manual/en/function.filesize.php#77518
          • 6726
          • 7,075 Posts
          Thanks a lot GaneshXL, I’ll try that last bit, I am mainly interrested by filesize... but I think both addition could interrest lots of MG users smiley

          Off to trial and I’ll report right away !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 6726
            • 7,075 Posts
            Hmmm, I tried addin the code

            $pictureTplData[’picture_filesize’] = size_readable(filesize($modx->config[’base_path’].$mg->path_to_gal."big_".$pics[$i][’filename’]));

            And then the following placeholder

            [+maxigallery.picture.filesize+]

            where I want it, but it returns nothing...

              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l&#39;outil id
              • 10449
              • 956 Posts
              OK, I just did a little test.

              For some reason, you have to use _ instead of . for these placeholders.

              So, in other words, use:

              [+maxigallery.picture_wh+] and [+maxigallery.picture_filesize+] in the tpl.

              :-)
                • 6726
                • 7,075 Posts
                Still doesn’t work for me, do I need to change anything to the previous modification of maxigallery.php code ?

                Or else it’s because I use it a bit differently.
                You can see it here : http://ns29452.ovh.net/~secusol/la-securite-solaire/espace-presse/banque-dimages/

                Only the thumbails are displayed, when the visitor clicks, I used embed with embedtype external and they see the bigimg.
                I used the [+maxigallery.picture_filesize+] placeholder in gallerypicturetpl.html not picturetpl.html (but I don’t see how it could make it not work, a placeholder is a placeholder, no matter which tpl I use it in).

                Here is what I did :

                [tt]<img src="[(base_url)][+maxigallery.path_to_gal+]tn_[+maxigallery.picture.filename+]" class="thumbnail" title="Télécharger la version haute résolution ([+maxigallery.picture_filesize+])" alt="Télécharger la version haute résolution ([+maxigallery.picture_filesize+])" />[/tt]

                The filesize should be in the tooltip between ( ) but it’s not...

                I tried both cached and uncached calls it doesn’t change anything...
                Any idea ?

                Thanks a lot for your help !
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l&#39;outil id
                  • 6726
                  • 7,075 Posts
                  I added the width and height and it works smiley

                  I used the first code

                  			$pictureTplData[’picture_height_big’] = $imagesize[1];
                  $pictureTplData[’picture_width_big’] = $imagesize[0];

                  and then the [+maxigallery.picture_width_big+] and [+maxigallery.picture_height_big+] placeholders.

                  Now I now there is something wrong with the filesize thing for some reason :
                  $pictureTplData[’picture_filesize’] = size_readable(filesize($modx->config[’base_path’].$mg->path_to_gal."big_".$pics[$i][’filename’]));

                  Does it work for you for filesize ?
                  If it does, I might have a path issue or something and if it doesn’t maybe there is something to tweak...
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 10449
                    • 956 Posts
                    It works here (http://www.screenlab.ch/gallery-test-maxigallery.html?pic=9). View source will give you:
                    <img src="/assets/galleries/124/708509605_f5ad31eb48.jpg" width="450" height="299" class="imageview" alt="Date : 2008-02-16 15:03:51 : 29.91 kB" />

                    I removed the "big_" part though:
                    $pictureTplData[’picture_filesize’] = size_readable(filesize($modx->config[’base_path’].$mg->path_to_gal . $pics[$i][’filename’]));

                    Did you include the size_readable() function in maxigallery.php? That’s a custom function to output kB, not bytes. I linked the func. above (a user-comment in the PHP page).

                    $pictureTplData[’picture_wh’] = $imagesize[3] works too, it generates the entire width="450" height="299" string
                      • 10449
                      • 956 Posts
                      It the file wasn’t so big, I’d post the entire modified maxigallery.php here...

                      One more thing: around line 755 or so, there’s two very similar places where you can insert your custom placeholder stuff:

                      a) if(file_exists($modx->config[’base_path’].$mg->path_to_gal."big_".$pics[$i][’filename’])){
                      b) if(file_exists($modx->config[’base_path’].$mg->path_to_gal.$pics[$i][’filename’])) {

                      I inserted it in both places. Maybe you only used it in the 1st or 2nd if() statement.