Support » Alpha/Beta/RC » adding classes to tall and wide images

  • Resolved nrrghh


    is this possible via the admin system?

    ie can I programically check width of image file and thus apply a class?


Viewing 2 replies - 1 through 2 (of 2 total)
  • hi

    indicates that can get at image width

    not being any kind of php expert

    how do I get at the width value

    so I can then test and add a class

    thanks in advance



    have figured it

    this by the way is so I can have a grid of floated li’s containing thumbnails & style based on image width

    in the themes function.php (well if you are hacking out from Sandbox)

    there is a chunk of code to style the Gallery


    $img_src = wp_get_attachment_image_src( $id, $size );

    you can then grab the width
    $img_width = $img_src[1]; // added for for width test

    which you need to do before
    $img_src = $img_src[0];

    then in the output code

    if ( $img_width == 150 ) { $output .= ' class="wide" '; } // test for grid width styling



Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding classes to tall and wide images’ is closed to new replies.