php阻止动态添加的垂直图像水平显示

php阻止动态添加的垂直图像水平显示,php,jquery,html,css,image,Php,Jquery,Html,Css,Image,我正在处理的一个简单cms存在以下问题: 我有一个简单的php函数,从指定目录获取图像元素,并将它们打印到html中 <?php if($row["imgs"] == TRUE){ ?> <div class="imrow"> <?php $dir = $row["folder"]; $img = glob($dir."*.{jpg,j

我正在处理的一个简单cms存在以下问题: 我有一个简单的php函数,从指定目录获取图像元素,并将它们打印到html中

<?php if($row["imgs"] == TRUE){ ?>
              <div class="imrow">
                <?php
                  $dir = $row["folder"];
                  $img = glob($dir."*.{jpg,jpeg,png}", GLOB_BRACE);
                  $tabing = 3;
                  $scale = sizeof($img);
                      for ($i = 0; $i < $tabing; $i++)  {
                echo '<img src="'.$img[$i].'" alt="image" />';
                  }
                ?>
              </div><?php }//closing the first if of images ?>
                (...)
<?php   if($row["imgs"] == TRUE) { ?>
            <div class="imrow">

          <?php
                for ($i = $tabing; $i < $scale; $i++)  {

                  if(!($i % $tabing) && ($i!=0)){echo '</div><div class="imrow">';}
                    echo '<img src="'.$img[$i].'" alt="image" />';


            }
          ?>
          </div>
          <?php }//second if closing ?>
并使用一个简单的jQuery函数进行布局

 $(".imrow").each(function () { // for every row
        var row = $(this); //it gives it a name
        var rowW = row.width(); //it seals it's width
        var imgW = 0; //it sets a image width variable
        var fixH = 600; //and get a fixed amount

        row.children().each(function () {
            $(this).css("height", fixH); //apply fixed height to element in order to get ratio
            imgW += $(this).width(); //get the width of this and
            $(this).css("height", "100%");
            arr.push($(this).attr("src")); // restore

        });
          row.css("height", rowW / (imgW / fixH) - 2);
    });
这里的问题是,添加的垂直图像中有一些变成了水平的 下面是它在文件夹中的外观

以及在网站上的结果:

编辑:在我看来,这是一个仅限于php的问题,因为当我分析chrome中的元素时,默认情况下图像在内部翻转,正如大家在这里看到的: 因此,我的第一个赌注是glob做错了什么

有没有人经历过这种情况,或者知道一种让glob正确获取一切的方法

请记住,此问题仅发生在部分图像上,而不是取决于显示图像的格式。
任何帮助都将非常有用

问题似乎是存储在描述正确方向的图像中的元数据

有一个
image-orientation
css属性应该用来以正确的方向显示图像,但它似乎不是


目前唯一的另一种解决方案是使用元数据编辑器编辑图像的元数据,或者在photoshop中打开图像并保存它们。

如果直接在chrome中打开图像会发生什么?(将图像直接拖动到Chrome中)。我觉得它不是glob,因为它只扫描目录并返回文件名列表,但不应该更改任何属性。还要看看是否属于你。在其他浏览器中也可以尝试。该网站在Firefox中的外观相同,同时将图像拖动到两种浏览器中会使其显示在正确的方向上。提供的链接中的答案确实解决了Firefox的问题,但仅此而已。其他人仍然存在问题。可能是因为您可能需要编辑这些图像的元数据。安德鲁,你是对的。在photoshop中打开文件并保存它们解决了这个问题。请写信并回答,这样我就可以接受了。
 $(".imrow").each(function () { // for every row
        var row = $(this); //it gives it a name
        var rowW = row.width(); //it seals it's width
        var imgW = 0; //it sets a image width variable
        var fixH = 600; //and get a fixed amount

        row.children().each(function () {
            $(this).css("height", fixH); //apply fixed height to element in order to get ratio
            imgW += $(this).width(); //get the width of this and
            $(this).css("height", "100%");
            arr.push($(this).attr("src")); // restore

        });
          row.css("height", rowW / (imgW / fixH) - 2);
    });