Support » Fixing WordPress » image height/width query into CSS

  • Hi!

    I am customizing my own photoblog theme using custom Single Post Templates to define layouts for landscape and portrait orientation. In each template, I am using a small amount of inline CSS to define the templates’ unique parameters, specifically the width/height of the page and wrapper divs.

    My question: is there a way to set up a query for these values for each image and insert them into the CSS dynamically (so that the container divs size accordingly)? Or do I need to set up custom fields for this and enter the width/height manually for each post?

    Also, I am using PhotoQ (if that helps).

    BTW: I’ve Googled like mad, but I’m totally at the novice level with the vernacular so if anyone has any ideas, they would be among the first. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • I was thinking something to the effect of:

    <style type="text/css">
    #page {width: <?php xxxxx(); ?>px;}
    #imagewrap {width: <?php xxxxx(); ?>px; position: relative}
    #image {height: <?php xxxxx(); ?>px; width: <?php xxxxx(); ?>px;}

    Can this be done (or is there a better way)?

    Thank you for all your help.

    You can’t use php within CSS really.

    You could possibly write some javascript that applies CSS, though.

    Jeremy Clark



    @pmek the way seanik is suggested would work fine, since the style will be inline on the php page it will work fine.

    It would probalby be simplier to use custom fields, but there is php GD function called getimagesize that will return height and width.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘image height/width query into CSS’ is closed to new replies.