简体   繁体   English

自动排序并调整为图库中的图像

[英]auto sort and resize to images in the gallery

I'm working on a gallery and I want it to be dynamically sorted and resized (with the original ratio). 我正在一家画廊上,我希望它可以动态排序和调整大小(以原始比例)。 In the end of the post I added a picture that describe what I want. 在帖子的末尾,我添加了一张描述我想要的图片。

Right now I have this code that includes array with all the photos and the code thet should display them: 现在,我有以下代码,其中包含所有照片的数组,并且代码thet应该显示它们:

<?php
    $works = array(
        1 => array("Chill", "elenby", "http://fc03.deviantart.net/fs71/i/2014/008/f/4/chill_by_elenby-d71g75m.jpg", "http://isrart.co.il/showthread.php?t=12072"),
        2 => array("Fenix", "Elis", "http://ufu.co.il/files/aydw724j81kcd2zx3az0.jpg", "http://isrart.co.il/showthread.php?t=12070"),
        3 => array("Dont panic", "Tzah", "http://oi41.tinypic.com/vwrjly.jpg", "http://isrart.co.il/showthread.php?t=12084"),
        4 => array("Summer Jam", "elenby", "http://fc09.deviantart.net/fs70/i/2014/003/7/3/summer_jam_by_elenby-d70q8sy.jpg", "http://isrart.co.il/showthread.php?t=12052"),
        5 => array("Ancient Facts", "Dangle", "http://isrart.co.il/attachment.php?attachmentid=4173&d=1388471618", "http://isrart.co.il/showthread.php?t=12032"),
        6 => array("SAVIOR", "daskull", "http://25.media.tumblr.com/c8d55b4371ad32250129e4e1aae530b6/tumblr_mzf8alBIOe1s4jk9mo1_1280.png", "http://isrart.co.il/showthread.php?t=12106"),
        7 => array("BFF", "roni yoffe", "http://isrart.co.il/attachment.php?attachmentid=4211&d=1389791848", "http://isrart.co.il/showthread.php?t=12108"),
        8 => array("New York City", "ChananGrenblatt", "https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-prn1/1492578_244031302429143_693411241_o.jpg", "http://isrart.co.il/showthread.php?t=12090"),
        9 => array("Envato", "impact", "http://fc09.deviantart.net/fs71/f/2014/005/7/2/envato_by_impact_design-d70ylnm.png", "http://isrart.co.il/showthread.php?t=12068"),
        10 => array("Crismes", "Tali", "http://ufu.co.il/files/i7ehgj692t5i3m6txrv0.jpg", "http://isrart.co.il/showthread.php?t=12031")
    );
    $date = "January 2014";
?> 

<html>
    <head>
        <title><?php echo $date; ?></title>
        <meta charset="UTF-8">
        <meta name="author" content="Vlad Gincher">
        <link rel="shortcut icon" href="favicon.ico">
        <link rel="stylesheet" href="bestofthemonth.css">
    </head>
    <body>
        <div class="body">
            <img src="isrart.png" alt="Isrart" title="<?php echo $date; ?>" /><br />
            <h1><?php echo $date; ?></h1>
            <div>
                <?php
                for ($i = 1; $i < count($works); $i++){
                    echo '
                        <div id="work'.$i.'">
                            <img src="'.$works[$i][2].'" alt="" />
                        </div>
                    ';
                }
                ?>
            </div>
        </div>
    </body>
</html>

Here is the picture (In the code I'll have much less images): 这是图片(在代码中,我将得到更少的图像): 我希望它像

As used in this solution? 如在此解决方案中使用的?

Demo 演示版

Tutorial 讲解

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM