We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7923
    • 4,213 Posts
    Try this, that should do it now, I took the time to try it myself before posting smiley You might want to set a height to the "picHolder" div to reserve the space to avoid jitter on the page when it removes the original picture and takes some time to load the new one. 300px seems to do it.

    From the js code, you can see what I did.. I chained the fade out and image removing, so that the image is not removed before it’s faded out.

    function showPic(url,title,descr,width,height) {
      $("#maxImage").fadeOut("fast", function(){
          $("#maxImage").remove();
          var image = new Image();
          $(image).attr({src: url, width: width, height: height, id: 'maxImage'}).load(function() {
            $(image).hide();
            $("#picHolder").append(image);
            $(image).fadeIn("fast");
          });
          
      });
      $("#maxTitle").html(title);
      $("#maxDescr").html(descr);
    }


    It would be really great if you could write instructions to the maxigallery wiki page how to do all this with jQuery as an alternative tutorial to the already existing one.


      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 29703
      • 217 Posts
      Yeh I was thinking of writing a tutorial, I definitely will once I get the whole thing working (and I get a spare moment).

      Unfortunately it’s now fading out but not in smiley
        • 7923
        • 4,213 Posts
        Hmm.. I tried the code and it works for me.. BUT, now that I thought of it, you can get rid of the "picHolder" div and use this js code instead, hopefully it works smiley

        function showPic(url,title,descr,width,height) {
          $("#maxImage").fadeOut("fast", function(){
              var image = new Image();
              $(image).attr({src: url, width: width, height: height, id: 'maxImage'}).load(function() {
                $(image).hide();
                $("#maxImage").attr({
                  src: url,
                  width: width,
                  height: height
                });
                $("#maxImage").fadeIn("fast");
                $("#maxTitle").html(title);
                $("#maxDescr").html(descr);
              });
          });
        }
        


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 29703
          • 217 Posts
          Sorry I’m being a prune, it works fine for me. This is absolutely brilliant, everything works perfectly (unless you’re logged into the manager but that shouldn’t matter).

          Thanks millions!
            • 7923
            • 4,213 Posts
            Yeah.. If you are logged into manager (and QuickEdit is in use), then mootools js library is included to the page and it will collide with jQuery. To get by that error, you need to use jQuery in non conflict mode, try this:

            Add this to the <head> of your site template after jQuery inclusion:

            <script>
                 jQuery.noConflict();
            </script>
            


            Then in the function replace all $ with jQuery so mootools code can still use $. You need to do the same thing to other parts where jQuery is used (eg the js code where it autoloads the first image).
            function showPic(url,title,descr,width,height) {
              jQuery("#maxImage").fadeOut("fast", function(){
                  var image = new Image();
                  jQuery(image).attr({src: url, width: width, height: height, id: 'maxImage'}).load(function() {
                    jQuery(image).hide();
                    jQuery("#maxImage").attr({
                      src: url,
                      width: width,
                      height: height
                    });
                    jQuery("#maxImage").fadeIn("fast");
                    jQuery("#maxTitle").html(title);
                    jQuery("#maxDescr").html(descr);
                  });
              });
            }
            


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 29703
              • 217 Posts
              Hi again,

              Thanks for everything - I’m just stuck on one tiny bit that I didn’t pick up on before. The photo’s title and description aren’t changing with the image. Is this something I can easily fix?

              Thanks.
                • 7923
                • 4,213 Posts
                The description and titles are not changing/showing because at least in the demo page you showed me didn’t have those maxTitle and maxDescr elements in the source at all..

                Eg. you need to add these somewhere where you want the title / description to show up:

                <p id="maxTitle"></p>
                <p id="maxDescr"></p>

                Please write a tutorial for this in the MaxiGallery wiki page once you have it working.. The tutorial doesn’t have to be much initially, community can correct it later, but it would be good to have at least your snippet calls and chunk contents etc there.. It would help me a lot when I could just refer to that tutorial when people are asking for the same thing..


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 29703
                  • 217 Posts
                  Quote from: doze at Oct 06, 2008, 08:11 AM

                  The description and titles are not changing/showing because at least in the demo page you showed me didn’t have those maxTitle and maxDescr elements in the source at all..

                  Eg. you need to add these somewhere where you want the title / description to show up:

                  <p id="maxTitle"></p>
                  <p id="maxDescr"></p>

                  Please write a tutorial for this in the MaxiGallery wiki page once you have it working.. The tutorial doesn’t have to be much initially, community can correct it later, but it would be good to have at least your snippet calls and chunk contents etc there.. It would help me a lot when I could just refer to that tutorial when people are asking for the same thing..

                  No worries, I’ll start writing the tutorial this evening.

                  My problem is that the alt tag needs to change as it’s using [+maxigallery.picture.title:htmlent+]. Is this simply not possible?

                  If not I’ll look for a workaround. . .
                    • 7923
                    • 4,213 Posts
                    Oh that.. You can do it in the js function just fine, use this:

                    Note that I removed the title and description lines at the bottom of the function if you are not using the html elements at all. I added the updating of the alt parameter and set it to the picture title variable. The picture description is not used anywhere now, should it be like that?
                    function showPic(url,title,descr,width,height) {
                      $("#maxImage").fadeOut("fast", function(){
                          var image = new Image();
                          $(image).attr({src: url, width: width, height: height, id: 'maxImage'}).load(function() {
                            $(image).hide();
                            $("#maxImage").attr({
                              src: url,
                              width: width,
                              height: height,
                              alt: title
                            });
                            $("#maxImage").fadeIn("fast");
                          });
                      });
                    }
                    


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 29703
                      • 217 Posts
                      Quote from: doze at Oct 06, 2008, 08:24 AM

                      Oh that.. You can do it in the js function just fine, use this:

                      Note that I removed the title and description lines at the bottom of the function if you are not using the html elements at all. I added the updating of the alt parameter and set it to the picture title variable. The picture description is not used anywhere now, should it be like that?
                      function showPic(url,title,descr,width,height) {
                        $("#maxImage").fadeOut("fast", function(){
                            var image = new Image();
                            $(image).attr({src: url, width: width, height: height, id: 'maxImage'}).load(function() {
                              $(image).hide();
                              $("#maxImage").attr({
                                src: url,
                                width: width,
                                height: height,
                                alt: title
                              });
                              $("#maxImage").fadeIn("fast");
                            });
                        });
                      }
                      


                      Ah okay this is my fault for trying to be clever. I’m sorry this is dragging out for so long.

                      I have wrapped the image that fades in and out in an
                      <a id="maxTitle" href="[+maxigallery.picture.title:htmlent+]" rel="shadowbox"></a>
                      because I want the fade image to be a link to an URL which I type in the title (I should’ve probably created a custom field right?).

                      I figured if I got the alt code working I could easily work out how to do this. Wrong.

                      This is my (probably abysmal) attempt:

                      <script type="text/javascript">
                      //<![CDATA[
                      function showPic(url,title,descr,width,height) {
                        $("#maxImage").fadeOut("fast", function(){
                            var image = new Image();
                            $(image).attr({src: url, width: width, height: height, href: title, id: 'maxImage'}).load(function() {
                              $(image).hide();
                              $("#maxImage").attr({
                                src: url,
                                width: width,
                                height: height
                              });
                              $("#maxTitle").attr({
                                href: title
                              });
                              $("#maxImage").fadeIn("fast");
                            });
                        });
                      }
                      //]]> 
                      </script>


                      A brief pointer would be awesome, then I’ll get right on the tutorial wink

                      Wahooooo! I’ve worked it out despite my complete Jquery stupidity:

                      <script type="text/javascript">
                      //<![CDATA[
                      function showPic(url,title,descr,width,height) {
                        $("#maxImage").fadeOut("fast", function(){
                            var image = new Image();
                            $(image).attr({src: url, width: width, height: height, id: 'maxImage'}).load(function() {
                              $(image).hide();
                              $("#maxImage").attr({
                                src: url,
                                width: width,
                                height: height,
                                alt: title
                              });
                              $("#maxImage").fadeIn("fast");
                              $("#maxTitle").attr({
                                href: title
                              });
                            });
                        });
                      }
                      //]]> 
                      </script>


                      I’m going to start work on the tutorial now that malarky is over with.