• I use this code (from the wordpress codex) for echo all images in a post as thumbnails.

    When you click on the thumbnails, they opens up in a new window, however I want them just replaced to the full size image on their left side.(Please view my live example here)

    <?php
    
    $args = array(
    	'post_type'   => 'attachment',
    	'numberposts' => -1,
    	'post_status' => 'any',
    	'post_parent' => $post->ID,
    	'exclude'     => get_post_thumbnail_id(),
    );
    
    $attachments = get_posts( $args );
    
    if ( $attachments ) {
    	foreach ( $attachments as $attachment ) {
    		the_attachment_link( $attachment->ID, false );
    	}
    }
    
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter caroline

    (@makeupedia)

    <script type="text/javascript">
    
    $('#product-img').click( function(event){
        event.preventDefault();
        var bigPath = $(this).attr('href');
        $('#productContent').html( "<img src=" + bigPath + " />" );
    });
    
    </script>

    Any ideas what I should do from here?
    Thanks!

    Thread Starter caroline

    (@makeupedia)

    I’m getting closer to a solution but would appreciate any help!

    What can I do about this script to print the correct URL?

    <script type="text/javascript">
    jQuery(document).ready(function($){
    
        var button = $('button');
    
        jQuery(button).on('click',function(){
    
            var button_id = $(this).data('id');
            var img_id = $(this).next('img').data('id');
    
            //console.log(button_id);
            //console.log(img_id);
    
            if(button_id === img_id){
                location.hash = '#'+img_id;
            }
    
        });
    });</script>

    This is the html:

      <?php

      $args = array(
      ‘post_type’ => ‘prefix_produkt’,
      ‘posts_per_page’ => -1
      );

      $myposts = get_posts( $args );

      foreach ( $myposts as $post ) {?>

    • <?php

      //echo get_the_post_thumbnail();
      $image = wp_get_attachment_url( get_the_post_thumbnail($post->ID));

      echo ‘<button class=”select-image” data-id=”‘.$attachment->ID.'”>Image ID</button><img src=”‘.$image.'” data-id=”‘.$post->ID.'”>’;

      ?>

    • <?php }
      wp_reset_postdata();?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Thumbnail links to full size (remove attachment link)’ is closed to new replies.