Page 1 of 5 123 ... LastLast
Results 1 to 10 of 44

Thread: max-width property and PHP

  1. #1
    Join Date
    Dec 2009
    Location
    NY NY USA
    Posts
    230
    Thanks
    158
    Thanked 1 Time in 1 Post

    Default max-width property and PHP

    Hi guys,

    Would you please show me how to apply the max-width property (or whatever is necessary) to the following code, so that the display of all size images will be limited to fit within a box 240X320, but still remain proportional to their actual size?

    Code:
    <div style=" padding-top:<?php echo($DownFromTop); ?>px;"><?php echo($ImageDisplay); ?></div>

    The code is for the following page of a site I work on... Promotional cell-phone screensaver

    When a large image like 640X960 (for the iPhone) is generated, its display on the following page must be made to fit within the 240X320 display box, but everything I've tried hasn't worked.


    Thanks,

    Kenny
    Last edited by KennyP; 08-12-2012 at 11:58 PM.

  2. #2
    Join Date
    Dec 2009
    Location
    NY NY USA
    Posts
    230
    Thanks
    158
    Thanked 1 Time in 1 Post

    Default

    The image imprint software has an include in which I was able to set the display size of the images...

    Code:
    $ImageDisplay = $ImageDisplay = "<img src='$FileLocation' alt='' width='240' height='320' border='0' align='middle'>";
    This would work except that images of different proportions display distorted.
    Last edited by KennyP; 08-13-2012 at 12:53 AM.

  3. #3
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Try

    Code:
    $ImageDisplay = "<img src='$FileLocation' alt='' max-width='240' max-height='320' border='0' align='middle'>";

  4. The Following User Says Thank You to keyboard For This Useful Post:

    KennyP (08-13-2012)

  5. #4
    Join Date
    Dec 2009
    Location
    NY NY USA
    Posts
    230
    Thanks
    158
    Thanked 1 Time in 1 Post

    Default

    Thanks very much for your reply keyboard. Unfortunately, max-width and max-height have no affect on the display. I entered the code as follows..

    Code:
    $ImageDisplay = "<img src='$FileLocation' alt='' max-width='240' max-height='320' border='0' align='middle'>";
    After generating a 640X960 iPhone screensaver it displays its actual size and breaks up the page.
    Last edited by keyboard; 05-24-2018 at 06:24 AM. Reason: Edited out name

  6. #5
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    This should work in all browsers except IE6 or less

    Code:
    $ImageDisplay = "<img src='$FileLocation' alt='' style="max-width:240px;max-height:320px;" border='0' align='middle'>";

  7. The Following User Says Thank You to keyboard For This Useful Post:

    KennyP (08-13-2012)

  8. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    The only thing that I would add to that is that this really has nothing to do with PHP specifically: it is a CSS issue.
    (You just happen to be using PHP to write your CSS.)

  9. The Following User Says Thank You to traq For This Useful Post:

    KennyP (08-13-2012)

  10. #7
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Try applying these CSS properties:
    Code:
    height: auto;
    max-height: 320px;
    width: auto;
    max-width: 240;
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  11. The Following User Says Thank You to bernie1227 For This Useful Post:

    KennyP (08-13-2012)

  12. #8
    Join Date
    Dec 2009
    Location
    NY NY USA
    Posts
    230
    Thanks
    158
    Thanked 1 Time in 1 Post

    Default

    Thanks again keyboard 1333.

    The code still has no affect on the display. However, for whatever it means, if I chage it either to
    Code:
    style='width:240px;max-height:320px;'
    or
    Code:
    style='max-width:240px;height:320px;'
    it does affect the display. But of course, this way it can work for only some of the smaller image sizes.

  13. #9
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    @KennyP -
    I tested the code that I gave you and it worked fine...
    What browser are you using?
    Do you have a link to your site with that code so we can see if something else is impacting it?
    Keyboard1333

  14. The Following User Says Thank You to keyboard For This Useful Post:

    KennyP (08-13-2012)

  15. #10
    Join Date
    Dec 2009
    Location
    NY NY USA
    Posts
    230
    Thanks
    158
    Thanked 1 Time in 1 Post

    Default

    Thanks to you also bernie1227. Like keyboard's code, your code affects the display only if one of the dimensions is set to width or height. Including max- on both for some reason makes them ineffectual.

    This is the page.

    Thank you bernie and keyboard for taking the time to check

    EDIT: I'm trying with IE8 and FF

    OK, the problem is only in IE, it is working in FF. Thank you so much! Can it be fixed to also work as well in IE?
    Last edited by keyboard; 05-24-2018 at 06:25 AM. Reason: Edited out name

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •