Support » Plugin: Hammy » [Plugin: Hammy] cant get the right break points

  • Resolved goodduck


    i cant seem to make this work properly. i set up the break points with what i think are correct breakpoints but it is not selecting what i want when the page loads.

    when i have #page-container as the content container it loads the next break point size up from what I want and when i have #content as the content container it loads the smallest break point size

    maybe i am not using the right content container

Viewing 9 replies - 1 through 9 (of 9 total)
  • example: i have a break point at 988, 989, 990, 991 (break points would be different in final version but im using those to understand what it is doing)

    i want it to load 989

    instead it does this:

    view image info: “990px × 649px (scaled to 989px × 648px)”

    Plugin Author Noel Tock


    A live example would be super helpful, do you have one?

    thanks. this is a live example.

    my break points will be 991 and 1247 ideally but in this example i have 991, 992, and 1247. I am on a 1024 wide screen and it should load the 991. instead it loads the 992 and jams it into a 991 space.

    i am using the plug in to allow people with larger monitors to see a larger version of the image. i guess this plug in is more for adapting to smaller screens not larger ones if that makes sense?

    Plugin Author Noel Tock


    Should work both ways, what is your container set too?

    my container is set to:


    thank you for the help with this

    I have tried a few different containers and the same thing happens.

    here is another example:

    container is set to .content.column-1

    break points: 640x, 990x, 991x, 992x, 1000x, 1001x, 1010x, 1024x, 1247x

    viewing this on a 1024 screen it is selecting 1000x as the break point and jamming the 1000px into 991px. i cant seem to understand why it picks 1000 as opposed to 1001 or 991 for that matter.

    Plugin Author Noel Tock


    Same here, that’s a weird one. I’ll try to review the code and see where it’s breaking.

    Sorry to reopen this older thread, but I had the exact same issue. The breakpoints in the media code were correct, but the image associated with the breakpoint was always one breakpoint larger than it should have been.

    I opened up the hammy.php code to see this:

    if ( ! preg_match( $ignorelist, $class ) ) {
                        // Get Sizes
                        $sizes = explode( ",", $options['hammy_breakpoints'] );
                        // Render Sizes
                        $i = 0;
                        $breakpoint = null;
                        // Output & Replace Strings
                        $newimage = '<picture class="hammy-responsive ' . $class . '" alt="' . $alt . '" title="' . $title . '">';
                        foreach ( $sizes as $size ) {
                            if ( $i == 0 ) {
                                $media = null;
                            } else {
                                $media = ' media="(min-width:' . $breakpoint . 'px)"';
                            if ( $size <= $width ) {
                                $resized_image = wpthumb( $original, 'width=' . $size . '&crop=0' );
                                $newimage .= '<source src="' . $resized_image . '"' . $media . '>';
                            $breakpoint = $size;

    I moved the $breakpoint = $size; from below $i++; to the beginning of the foreach block and the correct image is now associated with the breakpoint.

    I’m sure this is a dirty hack. My knowledge of PHP and this code is very, very limited but it appears to work. Is there a reason why the breakpoint was set AFTER it was used in the loop?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Hammy] cant get the right break points’ is closed to new replies.