Hi,
I need a more perfect random picture block of Advanced Menu Manager. I want use a square images with a different height. So, here a patch for replace thumbnails images with square with width and height from 'Height of menu block' option:
amm_pip.class.inc.php @@ -476,6 +476,12 @@ $result = pwg_query($sql); if($result) { + $height = $this->config['amm_randompicture_height']; + if($height == 0) + $derivative_params = ImageStdParams::get_by_type(IMG_SQUARE); + else + $derivative_params = ImageStdParams::get_custom($height, $height, 1, $height, $height); + while($row=pwg_db_fetch_assoc($result)) { $row['section']='category'; @@ -486,7 +492,8 @@ ); $row['link']=make_picture_url($row); - $row['thumb']=DerivativeImage::thumb_url(array('id'=>$row['image_id'], 'path'=>$row['path'])); + $infos = array('id'=>$row['image_id'], 'path'=>$row['path']); + $row['thumb']=DerivativeImage::url($derivative_params, $infos); $returned[]=$row; }
Will be greate if somebody add a 'Enable square' option into config and add this code to svn.
Offline
And patch for updated rotation script:
Index: amm_pip.class.inc.php =================================================================== @@ -86,7 +86,7 @@ ) { GPCCore::addHeaderJS('jquery', 'themes/default/js/jquery.min.js'); - GPCCore::addHeaderJS('amm.randomPictPublic', 'plugins/AMenuManager/js/amm_randomPictPublic.js', array('jquery')); +// GPCCore::addHeaderJS('amm.randomPictPublic', 'plugins/AMenuManager/js/amm_randomPictPublic.js', array('jquery')); $block->set_title(base64_decode($this->config['amm_randompicture_title'][$user['language']])); $block->template=dirname(__FILE__).'/menu_templates/menubar_randompic.tpl'; Index: menu_templates/menubar_randompic.js.tpl =================================================================== @@ -19,5 +19,50 @@ }; </script> {/literal} + +<script type="text/javascript"> +$(function() { + $('#iamm_ill0').width({$data.blockHeight}); + $('#iamm_ill0').height({$data.blockHeight}); + + var randomPict = randomPictOpt['pictures']; + if (randomPict.length > 1) { + $('#iamm_ill0 a').attr("href", randomPict[0]['link']); + $('#iamm_ill0 img').attr("src", randomPict[0]['thumb']); + + var nextFaderPos = 1; + var duration = 400; + var pause = false; + + $('#iamm_ill0 img').after('<img id="iammRPicImg">'); + $('#iamm_ill0 img').eq(1).hide(); + $('#iamm_ill0 img')[1].src = randomPict[1]['thumb']; + $('#iamm_ill0 img').css('position', 'absolute'); + + $('#iamm_ill0').hover(function() { + pause = true; + },function() { + pause = false; + }); + + function doRotate() { + if ($('#iamm_ill0 img')[1].complete) { + if(!pause) { + $('#iamm_ill0 img').first().fadeOut(duration, function() { + nextFaderPos = (nextFaderPos + 1) % randomPict.length; + $('#iamm_ill0 img')[1].src = randomPict[nextFaderPos]['thumb']; + }); + $('#iamm_ill0 img').first().insertAfter($('#iamm_ill0 img').eq(1)); // swap + $('#iamm_ill0 img').first().fadeIn(duration); + setTimeout(function() { + $('#iamm_ill0 a').attr("href", randomPict[nextFaderPos]['link']); + }, duration/3); + } + } + } + + var rotate = setInterval(doRotate, {$data.delay}); + } +}); +</script> Index: menu_templates/menubar_randompic.tpl =================================================================== @@ -4,7 +4,7 @@ <dd id="irandompicdd" class="randompicdd"> <div id="irandompicinner" class="illustration"> <div class="ammillustrationc"> - <div id="iamm_ill0" class="ammillustration"> + <div id="iamm_ill0" class="ammillustration" style="text-align: left;"> <span id='iammRPicNameO' style='display:none;'></span> <span id='iammRPicCommentO' style='display:none;'></span> <a id='iammRPicLink' ><img id="iammRPicImg"/></a>
This enable lazy loading for random image block (picture name and comment not yet work), pause rotation when cursor under image.
Last edited by JanisV (2014-09-25 17:43:08)
Offline
One more improvements:
amm_pip.class.inc.php @@ -476,9 +477,15 @@ $result = pwg_query($sql); if($result) { while($row=pwg_db_fetch_assoc($result)) { - $row['section']='category'; + $row['section']='categories'; $row['category']=array( 'id' => $row['catid'], 'name' => $row['name'],
This fix change change image link to image in album, not in set of all images. Useful for very large galleries.
Offline
Hi
Pierrick could allow you to commit for that plugin then we add you as co author on the PEM
Offline
JanisV, now you have write access on http://piwigo.org/svn/extensions/AMenuManager
Offline
and you're now co author of AMM :)
Offline
As often discussed with mistic and ddtddt, I don't think it's a good idea (for the long run) to maintain Advanced Menu Manager. We'd better create several simpler plugins (not based on plugin GPC) :
* Menu Random Photo
* Custom Menu
* Menu Links
(* Album to Menu Block)
+ core features to manage content of menus "Menus & Specials"
That would make the whole system much simpler to maintain (if code is simpler than AMenuManager)
Offline
flop25 wrote:
and you're now co author of AMM :)
Not yet, first I request the authorization of grum :-)
Offline
plg wrote:
As often discussed with mistic and ddtddt, I don't think it's a good idea (for the long run) to maintain Advanced Menu Manager. We'd better create several simpler plugins (not based on plugin GPC) :
* Menu Random Photo
* Custom Menu
* Menu Links
(* Album to Menu Block)
+ core features to manage content of menus "Menus & Specials"
That would make the whole system much simpler to maintain (if code is simpler than AMenuManager)
Yes, I will move Menu Random Photo with my changes into separate plugin without extra features.
I'm not more need write access to AMM.
Offline
OK, perfect. Make your code simple :-) If you study code of the random picture, you will see that I have implemented a cache to avoid to many SQL query with ORDER BY RAND() because it is very slow on big galleries.
Offline
All improvements implemented in [extension by JanisV] Menu Random Photo
Offline