• Resolved nrrghh

    (@nrrghh)


    is this possible via the admin system?

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

    m

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nrrghh

    (@nrrghh)

    hi

    https://codex.www.ads-software.com/Function_Reference/wp_get_attachment_image_src

    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

    m

    Thread Starter nrrghh

    (@nrrghh)

    hi

    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

    find

    $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

    enjoy

    m

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