• Resolved mrced

    (@mrced)


    Hi,
    I have a problem with menu image.
    All my images are in wrong position with hover effect.
    I took a look at the code and I have a question :
    In function menu_image_nav_menu_item_title_filter (ligne 508 in menu-image.php)
    There is those lines :

    if ( $item->thumbnail_hover_id ) {
    $this->setUsedAttachments( $image_size, $item->thumbnail_hover_id );
    $hover_image_src = wp_get_attachment_image_src( $item->thumbnail_hover_id, $image_size );
    $margin_size = $hover_image_src[1];
    $image = “<span class=’menu-image-hover-wrapper’>”;
    $image .= wp_get_attachment_image( $item->thumbnail_id, $image_size, false, “class=menu-image {$class}” );
    $image .= wp_get_attachment_image(
    $item->thumbnail_hover_id, $image_size, false, array(
    ‘class’ => “hovered-image {$class}”,
    ‘style’ => “margin-left: -{$margin_size}px;”,
    )
    );
    $image .= ‘</span>’;
    }

    So, the margin_size is equal to the hover image size.
    This not working when I put only an image (with hover) without text because the margin-left is (- *image size*)px.
    I have made a little modifcation to resolve the problem in my case :

    if ( $item->thumbnail_hover_id ) {
    $this->setUsedAttachments( $image_size, $item->thumbnail_hover_id );
    $hover_image_src = wp_get_attachment_image_src( $item->thumbnail_hover_id, $image_size );
    $margin_size = ($hover_image_src[1])/2 + ($hover_image_src[1])*0.033;
    $image = “<span class=’menu-image-hover-wrapper’>”;
    $image .= wp_get_attachment_image( $item->thumbnail_id, $image_size, false, “class=menu-image {$class}” );
    $image .= wp_get_attachment_image(
    $item->thumbnail_hover_id, $image_size, false, array(
    ‘class’ => “hovered-image {$class}”,
    ‘style’ => “margin-left: -{$margin_size}px;”,
    )
    );
    $image .= ‘</span>’;
    }

    It works perfectly but I have to make this modification frequently…
    Is there any way to put the modification in functin.php ?

    Thanks a lot

    Cédric ( sorry for my english, I’m french)

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Position problem with hover’ is closed to new replies.