diff options
| author | 2013-06-14 20:45:00 +0200 | |
|---|---|---|
| committer | 2013-06-14 20:45:00 +0200 | |
| commit | 1d459af0464eb2cdbdaaaf1122e1681210fdffea (patch) | |
| tree | a803a6f2fbad70fbbf2bfd6c2a1b33daedbfacca /app | |
| parent | 746ae4b33a2e7a83d2623291c02d7b4292247103 (diff) | |
Fix issue #75 : chargement des images en lazyload, reste à le rendre optionnel
Diffstat (limited to 'app')
| -rw-r--r-- | app/App_FrontController.php | 1 | ||||
| -rw-r--r-- | app/views/index/index.phtml | 10 | ||||
| -rw-r--r-- | app/views/javascript/main.phtml | 6 |
3 files changed, 14 insertions, 3 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php index 77261280e..5729a115d 100644 --- a/app/App_FrontController.php +++ b/app/App_FrontController.php @@ -56,6 +56,7 @@ class App_FrontController extends FrontController { View::appendScript ('https://login.persona.org/include.js'); } View::appendScript (Url::display ('/scripts/jquery.js')); + View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js')); View::appendScript (Url::display ('/scripts/notification.js')); } diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 9974a9b0b..7037b2405 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,4 +1,12 @@ <?php +function lazyimg($content) { + return preg_replace( + '/<img([^<]+)src=([\'"])([^"\']*)([\'"])([^<]*)>/i', + '<img$1src="' . Url::display('/data/grey.gif') . '" data-original="$3"$5>', + $content + ); +} + $output = Request::param ('output', 'normal'); if ($output == 'rss') { @@ -58,7 +66,7 @@ if ($output == 'rss') { <h1 class="title"><?php echo $item->title (); ?></h1> <?php $author = $item->author (); ?> <?php echo $author != '' ? '<div class="author">' . Translate::t ('by_author', $author) . '</div>' : ''; ?> - <?php echo $item->content (); ?> + <?php echo lazyimg($item->content ()); ?> </div> <ul class="horizontal-list bottom"> diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index e6c882333..443f62c31 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -109,8 +109,8 @@ function mark_favorite (active) { } function init_img () { - $(".flux .content img").each (function () { - if ($(this).width () > ($("#stream .content").width()) / 2) { + $(".flux_content .content img").each (function () { + if ($(this).width () > ($(".flux_content .content").width()) / 2) { $(this).addClass("big"); } }); @@ -125,6 +125,8 @@ function init_posts () { <?php } ?> init_img (); + // TODO rendre optionnel + $(".flux .content img").lazyload(); if (hide_posts) { $(".flux:not(.active) .flux_content").hide (); |
