problem displaying images as thumbnails

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Davies

    #1

    problem displaying images as thumbnails

    Hello
    Im having problems displaying my images as thumbnails in a table. My code
    for producing the new width and height from the original image is as follows
    *************** *************** *************** *****
    if ($ImagePath) {
    //$Image = WEB_ROOT . 'images/PupilTester/' . $ImagePath;
    $Image = 'images/PupilTester/' . $ImagePath;
    } else {
    $Image ='images/PupilTester/nopicture.bmp';
    }

    $size = getimagesize($i mage);
    $height = $size[1];
    $width = $size[0];
    if ($height > 150)
    {
    $height = 150;
    $percent = ($size[1] / $height);
    $width = ($size[0] / $percent);
    }
    else if ($width > 150)
    {
    $width = 150;
    $percent = ($size[0] / $width);
    $height = ($size[1] / $percent);
    }
    //echo "<img src\"image/path/image.jpg\" height=\"$heigh t\"
    width=\"$width\ " />";
    *************** *************** *************** *************** **

    and in my table to display the thumbnail I have

    *************** *************** *************** *************** **
    <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
    ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >
    </div></td>
    </tr>
    *************** *************** *************** *************** ****
    However the images are not showing at all. The cells of the table are blank.
    But if I use

    *************** *************** ***************
    <td><img src=<?php echo $Image; ?>></td>
    </tr>
    *************** *************** *************
    The images show full size as normal. Can anyone see where Ive gone wrong


    Thaks
    Ian


  • Stefan Rybacki

    #2
    Re: problem displaying images as thumbnails

    Ian Davies wrote:[color=blue]
    > Hello
    > Im having problems displaying my images as thumbnails in a table. My code
    > for producing the new width and height from the original image is as follows
    > *************** *************** *************** *****
    > if ($ImagePath) {
    > //$Image = WEB_ROOT . 'images/PupilTester/' . $ImagePath;
    > $Image = 'images/PupilTester/' . $ImagePath;
    > } else {
    > $Image ='images/PupilTester/nopicture.bmp';
    > }
    >
    > $size = getimagesize($i mage);
    > $height = $size[1];
    > $width = $size[0];
    > if ($height > 150)
    > {
    > $height = 150;
    > $percent = ($size[1] / $height);
    > $width = ($size[0] / $percent);
    > }
    > else if ($width > 150)
    > {
    > $width = 150;
    > $percent = ($size[0] / $width);
    > $height = ($size[1] / $percent);
    > }
    > //echo "<img src\"image/path/image.jpg\" height=\"$heigh t\"
    > width=\"$width\ " />";
    > *************** *************** *************** *************** **
    >
    > and in my table to display the thumbnail I have
    >
    > *************** *************** *************** *************** **
    > <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
    > ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >
    > </div></td>
    > </tr>
    > *************** *************** *************** *************** ****
    > However the images are not showing at all. The cells of the table are blank.
    > But if I use
    >
    > *************** *************** ***************
    > <td><img src=<?php echo $Image; ?>></td>
    > </tr>
    > *************** *************** *************
    > The images show full size as normal. Can anyone see where Ive gone wrong
    >[/color]

    Wrong approach.

    Use a separate script for showing the images

    <img src="showthumbn ail.php?img=xxx xxx">

    Regards
    Stefan

    [color=blue]
    > Thaks
    > Ian
    >
    >[/color]

    Comment

    • Oli Filth

      #3
      Re: problem displaying images as thumbnails

      Ian Davies said the following on 18/10/2005 20:14:[color=blue]
      > Hello
      > Im having problems displaying my images as thumbnails in a table. My code
      > for producing the new width and height from the original image is as follows[/color]
      <...SNIP CODE...>[color=blue]
      >
      > and in my table to display the thumbnail I have
      >
      > *************** *************** *************** *************** **
      > <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
      > ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >
      > </div></td>
      > </tr>
      > *************** *************** *************** *************** ****
      > However the images are not showing at all. The cells of the table are blank.
      > But if I use
      >
      > *************** *************** ***************
      > <td><img src=<?php echo $Image; ?>></td>
      > </tr>
      > *************** *************** *************
      > The images show full size as normal. Can anyone see where Ive gone wrong
      >[/color]

      Wouldn't the simplest thing to do be to look at the HTML source in the
      browser, and ensure that the correct HTML is being output by PHP? If it
      isn't, then correct PHP code accordingly...


      --
      Oli

      Comment

      • Oli Filth

        #4
        Re: problem displaying images as thumbnails

        Stefan Rybacki said the following on 18/10/2005 20:23:[color=blue]
        > Ian Davies wrote:
        >[color=green]
        >> Hello
        >> Im having problems displaying my images as thumbnails in a table. My code
        >> for producing the new width and height from the original image is as
        >> follows[/color][/color]
        <...SNIP CODE...>[color=blue][color=green]
        >> The images show full size as normal. Can anyone see where Ive gone wrong
        >>[/color]
        >
        > Wrong approach.
        >
        > Use a separate script for showing the images
        >
        > <img src="showthumbn ail.php?img=xxx xxx">
        >[/color]

        Not in this case. The OP is outputting the image URL, not the image data
        itself...


        --
        Oli

        Comment

        • Ian Davies

          #5
          Re: problem displaying images as thumbnails

          Hello
          Here is part of the source viewed from the browser. It looks like the
          correct images are being found but it looks like the width and height
          variables are not working. I am new to php and despite trying a few
          alterations to the syntax am not having much luck.

          Also I am outputing the images themselves not the urls

          Ian
          *************** *************** *************** **************[color=blue]
          >[/color]
          </div></td>
          <td rowspan="5" valign="top">11 &nbsp;</td>
          <td rowspan="5" valign="top">Me tal plates were inserted into 3 shoot
          tips (below). Which shoot would grow to the right?</td>
          <td rowspan="5" valign="top"><d iv align="center"> </div>
          Type answer (Diagram)</td>
          <td valign="top"><d iv align="left"></div> </td>
          <td rowspan="5" valign="top"><d iv align="left"><i mg
          src=images/PupilTester/PlantHormones.j pg width= height= >
          </div></td>
          "Oli Filth" <catch@olifilth .co.uk> wrote in message
          news:CWb5f.198$ S_1.145@newsfe5-win.ntli.net...[color=blue]
          > Ian Davies said the following on 18/10/2005 20:14:[color=green]
          > > Hello
          > > Im having problems displaying my images as thumbnails in a table. My[/color][/color]
          code[color=blue][color=green]
          > > for producing the new width and height from the original image is as[/color][/color]
          follows[color=blue]
          > <...SNIP CODE...>[color=green]
          > >
          > > and in my table to display the thumbnail I have
          > >
          > > *************** *************** *************** *************** **
          > > <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo[/color][/color]
          $Image;[color=blue][color=green]
          > > ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >
          > > </div></td>
          > > </tr>
          > > *************** *************** *************** *************** ****
          > > However the images are not showing at all. The cells of the table are[/color][/color]
          blank.[color=blue][color=green]
          > > But if I use
          > >
          > > *************** *************** ***************
          > > <td><img src=<?php echo $Image; ?>></td>
          > > </tr>
          > > *************** *************** *************
          > > The images show full size as normal. Can anyone see where Ive gone wrong
          > >[/color]
          >
          > Wouldn't the simplest thing to do be to look at the HTML source in the
          > browser, and ensure that the correct HTML is being output by PHP? If it
          > isn't, then correct PHP code accordingly...
          >
          >
          > --
          > Oli[/color]


          Comment

          • Ewoud Dronkert

            #6
            Re: problem displaying images as thumbnails

            Ian Davies wrote:[color=blue]
            > $Image ='images/PupilTester/nopicture.bmp';[/color]

            Bad idea to use a BMP on the web. Try PNG (or GIF).
            [color=blue]
            > $size = getimagesize($i mage);[/color]

            Variable names are case sensitive! Use $image or $Image consistently.
            [color=blue]
            > <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
            > ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >[/color]

            Use quotation marks to enclose tag parameter values in HTML, but not when
            echoing PHP variables:

            <img src="<?php echo $Image; ?>"
            width="<?php echo $width; ?>"
            height="<?php echo $height; ?>">

            --
            E. Dronkert

            Comment

            • Ian Davies

              #7
              Re: problem displaying images as thumbnails

              Found it. Two problems

              *************** *************** **********
              $size = getimagesize($i mage);
              *************** *************** *********
              should be
              *************** *************** ***********
              $size = getimagesize($I mage);
              *************** *************** **********
              case sensitive (silly me)

              also in the table to display thumbnails
              *************** *************** **********
              <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
              ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >
              *************** *************** *************** *************** *****
              should be
              *************** *************** ************
              <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
              ?> width= "<?php echo $width?>" height= "<?php echo $height?>">
              *************** *************** ************

              Thanks for your help
              Ian


              "Ian Davies" <iandan.dav@vir gin.net> wrote in message
              news:4cc5f.64$6 5.27@newsfe6-win.ntli.net...[color=blue]
              > Hello
              > Here is part of the source viewed from the browser. It looks like the
              > correct images are being found but it looks like the width and height
              > variables are not working. I am new to php and despite trying a few
              > alterations to the syntax am not having much luck.
              >
              > Also I am outputing the images themselves not the urls
              >
              > Ian
              > *************** *************** *************** **************[color=green]
              > >[/color]
              > </div></td>
              > <td rowspan="5" valign="top">11 &nbsp;</td>
              > <td rowspan="5" valign="top">Me tal plates were inserted into 3[/color]
              shoot[color=blue]
              > tips (below). Which shoot would grow to the right?</td>
              > <td rowspan="5" valign="top"><d iv align="center"> </div>
              > Type answer (Diagram)</td>
              > <td valign="top"><d iv align="left"></div> </td>
              > <td rowspan="5" valign="top"><d iv align="left"><i mg
              > src=images/PupilTester/PlantHormones.j pg width= height= >
              > </div></td>
              > "Oli Filth" <catch@olifilth .co.uk> wrote in message
              > news:CWb5f.198$ S_1.145@newsfe5-win.ntli.net...[color=green]
              > > Ian Davies said the following on 18/10/2005 20:14:[color=darkred]
              > > > Hello
              > > > Im having problems displaying my images as thumbnails in a table. My[/color][/color]
              > code[color=green][color=darkred]
              > > > for producing the new width and height from the original image is as[/color][/color]
              > follows[color=green]
              > > <...SNIP CODE...>[color=darkred]
              > > >
              > > > and in my table to display the thumbnail I have
              > > >
              > > > *************** *************** *************** *************** **
              > > > <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo[/color][/color]
              > $Image;[color=green][color=darkred]
              > > > ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >
              > > > </div></td>
              > > > </tr>
              > > > *************** *************** *************** *************** ****
              > > > However the images are not showing at all. The cells of the table are[/color][/color]
              > blank.[color=green][color=darkred]
              > > > But if I use
              > > >
              > > > *************** *************** ***************
              > > > <td><img src=<?php echo $Image; ?>></td>
              > > > </tr>
              > > > *************** *************** *************
              > > > The images show full size as normal. Can anyone see where Ive gone[/color][/color][/color]
              wrong[color=blue][color=green][color=darkred]
              > > >[/color]
              > >
              > > Wouldn't the simplest thing to do be to look at the HTML source in the
              > > browser, and ensure that the correct HTML is being output by PHP? If it
              > > isn't, then correct PHP code accordingly...
              > >
              > >
              > > --
              > > Oli[/color]
              >
              >[/color]


              Comment

              • Stefan Rybacki

                #8
                Re: problem displaying images as thumbnails

                Oli Filth wrote:[color=blue]
                > Stefan Rybacki said the following on 18/10/2005 20:23:
                >[color=green]
                >> Ian Davies wrote:
                >>[color=darkred]
                >>> Hello
                >>> Im having problems displaying my images as thumbnails in a table. My
                >>> code
                >>> for producing the new width and height from the original image is as
                >>> follows[/color][/color]
                >
                > <...SNIP CODE...>
                >[color=green][color=darkred]
                >>> The images show full size as normal. Can anyone see where Ive gone wrong
                >>>[/color]
                >>
                >> Wrong approach.
                >>
                >> Use a separate script for showing the images
                >>
                >> <img src="showthumbn ail.php?img=xxx xxx">
                >>[/color]
                >
                > Not in this case. The OP is outputting the image URL, not the image data
                > itself...
                >[/color]

                Damn, you're right. I should better read. ;) Well the subject made me think he is creating
                real thumbnails not just faked ones.

                Regards
                Stefan

                Comment

                • Ian Davies

                  #9
                  Re: problem displaying images as thumbnails

                  Thanks
                  Trial and error brought me to the same conclusion
                  I will remember this
                  Ian

                  "Ewoud Dronkert" <firstname@last name.net.invali d> wrote in message
                  news:dnkal1dq7c dv9guufjef957h5 kblpd2bqf@4ax.c om...[color=blue]
                  > Ian Davies wrote:[color=green]
                  > > $Image ='images/PupilTester/nopicture.bmp';[/color]
                  >
                  > Bad idea to use a BMP on the web. Try PNG (or GIF).
                  >[color=green]
                  > > $size = getimagesize($i mage);[/color]
                  >
                  > Variable names are case sensitive! Use $image or $Image consistently.
                  >[color=green]
                  > > <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo[/color][/color]
                  $Image;[color=blue][color=green]
                  > > ?> width= <?php echo "$width"?> height= <?php echo "$height"?> >[/color]
                  >
                  > Use quotation marks to enclose tag parameter values in HTML, but not when
                  > echoing PHP variables:
                  >
                  > <img src="<?php echo $Image; ?>"
                  > width="<?php echo $width; ?>"
                  > height="<?php echo $height; ?>">
                  >
                  > --
                  > E. Dronkert[/color]


                  Comment

                  • Stefan Rybacki

                    #10
                    Re: problem displaying images as thumbnails

                    Ian Davies wrote:[color=blue]
                    > Hello
                    > Here is part of the source viewed from the browser. It looks like the
                    > correct images are being found but it looks like the width and height
                    > variables are not working. I am new to php and despite trying a few
                    > alterations to the syntax am not having much luck.
                    >
                    > Also I am outputing the images themselves not the urls[/color]

                    no you don't. $Image contains the url to the image not the image data itself.
                    Ewoud gave you a good hint, which you should follow.

                    Regards
                    Stefan
                    [color=blue]
                    >...
                    >
                    >
                    >[/color]

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: problem displaying images as thumbnails

                      Ewoud Dronkert wrote:[color=blue]
                      > Ian Davies wrote:
                      >[color=green]
                      >> $Image ='images/PupilTester/nopicture.bmp';[/color]
                      >
                      >
                      > Bad idea to use a BMP on the web. Try PNG (or GIF).
                      >
                      >[color=green]
                      >> $size = getimagesize($i mage);[/color]
                      >
                      >
                      > Variable names are case sensitive! Use $image or $Image consistently.
                      >
                      >[color=green]
                      >> <td rowspan="5" valign="top"><d iv align="left"><i mg src=<?php echo $Image;
                      >>?> width= <?php echo "$width"?> height= <?php echo "$height"?> >[/color]
                      >
                      >
                      > Use quotation marks to enclose tag parameter values in HTML, but not when
                      > echoing PHP variables:
                      >
                      > <img src="<?php echo $Image; ?>"
                      > width="<?php echo $width; ?>"
                      > height="<?php echo $height; ?>">
                      >[/color]

                      Actually, quotes are not required for numeric data like height and
                      width. But it doesn't hurt and is a good habit to get into.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Ewoud Dronkert

                        #12
                        Re: problem displaying images as thumbnails

                        Jerry Stuckle wrote:[color=blue][color=green]
                        >> Use quotation marks to enclose tag parameter values in HTML[/color]
                        >
                        > Actually, quotes are not required for numeric data[/color]

                        Yeah but they are for XHTML conformance. I always like to make my pages at
                        least XHTML 1.0 Transitional conformant.

                        --
                        E. Dronkert

                        Comment

                        Working...