WordPress.org

Ready to get started?Download WordPress

Forums

Hammy
[resolved] cant get the right break points (10 posts)

  1. goodduck
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/extend/plugins/hammy/

  2. goodduck
    Member
    Posted 1 year ago #

    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)"

  3. Noel Tock
    Human Made
    Plugin Author

    Posted 1 year ago #

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

  4. goodduck
    Member
    Posted 1 year ago #

    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.

    http://expokinetic.com/?p=131

    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?

  5. Noel Tock
    Human Made
    Plugin Author

    Posted 1 year ago #

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

  6. goodduck
    Member
    Posted 1 year ago #

    my container is set to:

    .wp-caption

    thank you for the help with this

  7. goodduck
    Member
    Posted 1 year ago #

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

  8. goodduck
    Member
    Posted 1 year ago #

    here is another example:

    http://expokinetic.com/?p=139

    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.

  9. Noel Tock
    Human Made
    Plugin Author

    Posted 1 year ago #

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

  10. peter.morris
    Member
    Posted 10 months ago #

    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 . '>';
                            }
                            $i++;
                            $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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.