Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter JonRWilson

    (@jonrwilson)

    Hi Sean,

    Thank you for the incredibly quick follow up and sorry for the bad review, I should have read this first.

    I had actually started at your website, but then went to your plug in, thinking it would solve the problem, but as we both now know, it doesn’t stop ghost traffic, which is significant. I didn’t know what ghost traffic was when I installed the plug in, and still don’t know the difference, since it seems to present itself the same, but I did know that the plug-in doesn’t stop it before installing, so the plug-in is accurately advertised, but doesn’t fulfill my needs.

    I also thought that I’d have to create a ga filter for every spam url, but as the article above shows, it’s possible to put them all in a single filter, so it’s not such a hassle after all (although an .htaccess code copy and paste would still be easier, since I could quickly use it for multiple domains).

    Sorry about the 1 star, it appears that wordpress doesn’t allow the modification/revision of reviews, so I can’t add stars even if the problem is resolved. This feels like a problem in itself….

    Thread Starter JonRWilson

    (@jonrwilson)

    Oh, it also doesn’t show Titles or Descriptions when in the lightbox. This is annoying, since I had them filled out for use in Simple Light Box, but with this plugin they no longer show. The Caption box does display, but it also displays on the post, as a caption below the image, which maybe people want, but I don’t, I just want the description when it’s in the lightbox.

    It also requires every post ever created to be opened and saved to get it to work. That’s a pretty laborious and unusual request from a plug in to get it to work.

    Hi Louy,

    Thanks for your quick reply!

    I was unaware of the inefficiencies and detrimental performance aspects involved in querying image sizes. I also don’t have a ton of posts, so last night I just went ahead with the process of “Quick Edit” + “Update”ing all my posts.

    I don’t understand what you mean by

    Also the plugin inserts the size attribute automatically when you use wp_get_attachment_link. So just use for your featured images.

    Do you mean that if I use wp_get_attachment_link instead of wp_get_attachment_image_src, it’ll automatically add the data-size, because the plug-in ties into wp_get_attachment_link? If so, thank you for the informational link, I’ll post the updated code when I figure it out (looks like it’ll be pretty similar to what I have), since I expect it to be useful for others using featured images.

    Thanks,
    Jon

    OK, I’ve made some progress and have modified my child theme single.php, which already included the addition of the featured image, but now also automatically inserts the data-size specific to the image being linked to:

    <!-- ADD FEATURED IMAGE & PhotoSwipe data-size="XXXxYYY" -->
    		<?php
    		if ( has_post_thumbnail() ) {
    			$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
    			$content = '<a data-size="' . $full_image_url[1] . 'x' . $full_image_url[2] . '" href="' . $full_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">' . get_the_post_thumbnail( $post_id, 'large' ) . '</a>';
    			echo $content;
    		}
    		?>

    Now I just need to figure out how to insert the data-size for all the linked images in a post and remove the automatic post modification.

    Looks like a modification of this will do the trick:

    /**
     * Attach a class to linked images' parent anchors
     * Works for existing content
     */
    function give_linked_images_class($content) {
    
      $classes = 'img'; // separate classes by spaces - 'img image-link'
    
      // check if there are already a class property assigned to the anchor
      if ( preg_match('/<a.*? class=".*?"><img/', $content) ) {
        // If there is, simply add the class
        $content = preg_replace('/(<a.*? class=".*?)(".*?><img)/', '$1 ' . $classes . '$2', $content);
      } else {
        // If there is not an existing class, create a class property
        $content = preg_replace('/(<a.*?)><img/', '$1 class="' . $classes . '" ><img', $content);
      }
      return $content;
    }
    
    add_filter('the_content','give_linked_images_class');

    Hi,
    Let me start by saying that I’m a novice and am happy that you’ve started turning PhotoSwipe into a full fledged plug in.

    That said, the idea of modifying every post rather than inserting data-size="XXXxYYY" in all the <a> tags with php, seems like a real backwards method of solving this problem. It dirties every post with this excess of information, that will remain, even if the plugin is uninstalled. IMHO plug-in’s should be totally “non-destructive” in their installation, leaving no trace of their presence if uninstalled.

    Additionally, this approach doesn’t work with featured images. I thought I’d be able to modify my singles.php file with the standard size of my images 1440×960, but then realized that a few of my header images are cropped down, so they’re now being stretched vertically if clicked on…

    Modifying this seems promising

    <?php
    list($width, $height, $type, $attr) = getimagesize("img/flag.jpg");
    echo "<img src=\"img/flag.jpg\" $attr alt=\"getimagesize() example\" />";
    ?>

    If I figure it out I’ll report back, since this plug-in is perfect otherwise and I would like to do what I can to help.

    Thanks,
    Jon

    Here is an update to this thread that both puts the code in context and ensures that the featured image will still be displayed even if Simple Lightbox (SLB) is deactivated. I’ve included the whole upper portion of my child theme’s single.php file to show where I’ve placed the php code for adding the featured image and simple lightbox. The update moves the } above echo $content; instead of below, which will ensure it’s displayed even if slb_activate does not exist.

    <?php get_header(); ?>
    
    <div id="coreContent">
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
          <div class="post single hentry">
           <h5 class="entry-title"><abbr class="published"><?php the_title(); ?></abbr></h5>
    
            <!-- ADD FEATURED IMAGE & SLB LINK TO FULL IMAGE -->
    		<?php
    		if ( has_post_thumbnail() ) {
    			$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
    			$content = '<a href="' . $full_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">' . get_the_post_thumbnail( $post_id, 'large' ) . '</a>';
    			if ( function_exists('slb_activate') ) {
    				$content = slb_activate($content);
    				}
    			echo $content;
    		}
    		?>
    
            <div class="postContent">

    haha! I got it. I couldn’t figure out how to NOT display the_post_thumbnail. Turns out you don’t use the_post_thumbnail if you don’t want it displayed. Instead you use get_the_post_thumbnail which seems to get the html string, but doesn’t display it until you echo. Here’s what it says in the codex:

    Note: To return the Post Thumbnail for use in your PHP code instead of displaying it, use: get_the_post_thumbnail()

    With this method you then use echo later and to have it displayed within the link.

    So, if you’re trying to display a large thumbnail (featured image) above your postContent div that links to the full image size and is picked up by Simple Light Box, this should work:

    <!-- ADD LARGE FEATURED IMAGE & LINK TO FULL IMAGE -->
    <?php
    if ( has_post_thumbnail() ) {
    	$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
    	$content = '<a href="' . $full_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">' . get_the_post_thumbnail( $post_id, 'large' ) . '</a>';
    	if ( function_exists('slb_activate') ) {
    		$content = slb_activate($content);
    	echo $content;
    	}
    }
    ?>

    Seems super basic now, but this is my first “written” (cobbled together) php.

    Thinking that maybe the variables were messing things up I’ve removed $echo1, $middle & $echo2, to prevent the_post_thumbnail from showing up before the html is inserted in front of the image, but that didn’t solve the problem.

    <?php
    if ( has_post_thumbnail() ) {
    	$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
    	$content = '<a href="' . $full_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">' . the_post_thumbnail( 'large' ) . '</a>';
    	if ( function_exists('slb_activate') ) {
    		$content = slb_activate($content);
    	echo $content;
    	}
    }
    ?>

    I’ve tried to cobble it together similarly to the person above, and I feel quite close to getting it to work, but it’s not putting the link around the image. Instead the link is after the image and thus useless. Can you tell what’s going on? I’ve tried to combine the code from Post Thumbnail Linking to Large Image Size (but to the full image, hence the lightbox):

    <?php
    if ( has_post_thumbnail() ) {
    	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
    	echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">';
    	the_post_thumbnail( 'thumbnail' );
    	echo '</a>';
    }
    ?>

    With Simple Light Box | Activate Anywhere | Usage:

    $content = 'content with links and stuff to activate';
    if ( function_exists('slb_activate') )
        $content = slb_activate($content);
    echo $content;

    To make:

    <!-- ADD FEATURED IMAGE & LINK TO FULL IMAGE -->
    		<?php
    		if ( has_post_thumbnail() ) {
    			$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
    			$echo1 = '<a href="' . $full_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">';
    			$middle = the_post_thumbnail( 'large' );
    			$echo2 = '</a>';
    			$content = $echo1 . $middle . $echo2;
    			if ( function_exists('slb_activate') ) {
    				$content = slb_activate($content);
    			echo $content;
    			}
    		}
    		?>

    Thank you for Simple Light Box!

    I too am having this problem with 1&1. Hopefully they’ll fix it up by the time the 2014 festivities have settled down and it’s time to make another post…Or perhaps 2014 will be the year to move to a big boy host. TBD

    If you’re getting the image upload http error during crunching, I found this to solve the problem.

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