1

ビデオ プラグインを使用してビデオへのリンクのギャラリーを生成するサイトを構築しています。問題は、これらの画像とリンクがテーブルに配置されていることです。これは、サイトのレスポンシブ デザインと互換性がありません。PHP 開発者ではなく Web デザイナーであるため、テーブルを生成するすべての要素を取り出して単純な div コンテナーに置き換える方法についてのこのコードを見ると途方にくれます。 PHPの人にとっては簡単です。

<table id="media_galery">
    <?php 
    $t = 0;

            for ($i = 0; $i < count($cArray); $i++ ) {
                $t++;
                $file = $cArray[$i];
                $remote = null;
                $name = $file->getFileName();
                $file_path = BASE_URL.DIR_REL.$file->getDownloadURL();
                $ak_d = FileAttributeKey::getByHandle('media_date'); 
                $date = $file->getAttribute($ak_d);

                $ak_a = FileAttributeKey::getByHandle('media_artwork'); 
                $image = $file->getAttribute($ak_a);
                if($image==null){
                    $image_path=$uh->getBlockTypeAssetsURL($bt).'/tools/mp3.png';
                }else{
                    $image = File::getByID($image->fID);
                    $image_path=$image->getURL();
                }


                $file_src = BASE_URL.DIR_REL.$file->getRelativePath();

                $ak_s = FileAttributeKey::getByHandle('media_audio'); 
                $audio = $file->getAttribute($ak_s);
                if($audio){
                    $audio_array = $mh->getMediaTypeOutput($audio);
                    $audio_path = $audio_array['path'];
                    $file_src = $audio_path;
                }

                $video = null;
                $ak_s = FileAttributeKey::getByHandle('media_video'); 
                $video = $file->getAttribute($ak_s);

                if($video){
                    $video_array = $mh->getMediaTypeOutput($video);
                    $video_path = $video_array['path'];
                    var_dump($video_array['id']);
                    $image_path = $mh->getMediaThumbnail($video_array['id'],$video_array['type']);
                    //$video_src = $video_path.'?width='.$width.'&height='.$height;
                    //$file_src = $video_src;
                    if($video_array['type'] == 'vimeo'){
                        $file_src = 'http://player.vimeo.com/video/'.$video_array['id'];
                    }else{
                        $file_src = $video_path;
                    }
                }
                ?>
                <td valign="top">

                    </a><img src="<?php  echo $image_path?>" href="#popup_prep" alt="<?php echo $file_src?>" class="<?php echo $playerID?>player_get<?php echo $i?> gallery_thumb" href="<?php echo $file_src?>"/>

                </td>
            <?php 
            if($t == $spread){
                $t=0;
                echo '</tr>';
            }
    }

    for($d=$t;$d<$spread;$d++){
        echo '<td></td>';
        if($t == $spread){
            echo '</tr>';
        }
    }
    ?>
    </table>

これについての助けをいただければ幸いです!!

4

1 に答える 1

0
<div id="media_galery">
    <?php 
    $t = 0;

            for ($i = 0; $i < count($cArray); $i++ ) {
                $t++;
                $file = $cArray[$i];
                $remote = null;
                $name = $file->getFileName();
                $file_path = BASE_URL.DIR_REL.$file->getDownloadURL();
                $ak_d = FileAttributeKey::getByHandle('media_date'); 
                $date = $file->getAttribute($ak_d);

                $ak_a = FileAttributeKey::getByHandle('media_artwork'); 
                $image = $file->getAttribute($ak_a);
                if($image==null){
                    $image_path=$uh->getBlockTypeAssetsURL($bt).'/tools/mp3.png';
                }else{
                    $image = File::getByID($image->fID);
                    $image_path=$image->getURL();
                }


                $file_src = BASE_URL.DIR_REL.$file->getRelativePath();

                $ak_s = FileAttributeKey::getByHandle('media_audio'); 
                $audio = $file->getAttribute($ak_s);
                if($audio){
                    $audio_array = $mh->getMediaTypeOutput($audio);
                    $audio_path = $audio_array['path'];
                    $file_src = $audio_path;
                }

                $video = null;
                $ak_s = FileAttributeKey::getByHandle('media_video'); 
                $video = $file->getAttribute($ak_s);

                if($video){
                    $video_array = $mh->getMediaTypeOutput($video);
                    $video_path = $video_array['path'];
                    var_dump($video_array['id']);
                    $image_path = $mh->getMediaThumbnail($video_array['id'],$video_array['type']);
                    //$video_src = $video_path.'?width='.$width.'&height='.$height;
                    //$file_src = $video_src;
                    if($video_array['type'] == 'vimeo'){
                        $file_src = 'http://player.vimeo.com/video/'.$video_array['id'];
                    }else{
                        $file_src = $video_path;
                    }
                }
                ?>
                <div class="img_div<?php if($t == ($spread + 1)){$t=0; echo ' first';}?>">

                    </a><img src="<?php  echo $image_path?>" href="#popup_prep" alt="<?php echo $file_src?>" class="<?php echo $playerID?>player_get<?php echo $i?> gallery_thumb" href="<?php echo $file_src?>"/>

                </div>
            <?php
       }

    ?>
    </div>

の値が何であるかはわかりませんが$spread、上記のコードを使用すると、次のような出力が得られます。

<div id="meda_galery">
   <div class="img_div">
      ...
   <div>
   <div class="img_div">
      ...
   <div>
   <div class="img_div first">
      ...
   <div>
   <div class="img_div">
      ...
   <div>
</div>

上記の例では、スプレッドが 2 (つまり 2 列) であると想定しています。各 div を左にフロートできますが、clear を使用して、「最初」のクラスでそれぞれの新しい行を開始します。

于 2013-08-03T05:36:08.283 に答える