• I’m just pondering and testing out various things on Tanzaku, and I’m frustrated by the way it forces the main image to be a permalink to the single post. I’ve dug around the functions.php and index.php file trying to find a way to stop this, and can’t quite see where it’s being changed.

    My understanding of it (and I’m fairly good with PHP, HTML, CSS but not more advance jQuery etc.) is that perhaps that information is not being extracted from the original post when the grid is created, ergo can’t be passed back to the final grid. I can’t see anywhere that the original could be pulled in, although I can see where the image URL is taken from, and where the permalink is inserted. (functions.php line 57)

    Anyway help or advice on how I can get this great theme to leave my links alone on the front page would be great.

    Oh, and the reason for this is to use Shadowbox directly from the front page, which will then show other images inserted as a gallery.

    Cheers!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Chris Billett

    (@chris-billett-2)

    Ok, so it seems that in functions.php the image information is being captured here:

    preg_match('/<img(?:.+?)src="(.+?)"(?:[^>]+?)>/', $content, $matches);
    	$img_url = ($matches[1]) ? $matches[1] : '';
    	//echo "\n<!-- $img_url -->\n";
    	if ($img_url) {
    		// first, try to get attributes.
    		$matches_w = $matches_h = array();
    		preg_match('/width="([0-9]+)"/', $matches[0], $matches_w);
    		preg_match('/height="([0-9]+)"/', $matches[0], $matches_h);
    		if ($matches_w[1] and $matches_h[1]) {
    			$w = $matches_w[1];
    			$h = $matches_h[1];
    		}
    		else {
    			// get original size info.
    			$upload_path = trim( get_option('upload_path') );
    			$mark = substr(strrchr($upload_path, "/"), 1); // default mark is 'uploads'
    			$split_url = split($mark, $img_url);
    			if ($split_url[1] != null) {
    				$img_path = $upload_path . $split_url[1];
    				list($w, $h) = @getimagesize($img_path);
    			}
    		}

    … but it doesn’t include the ‘a=href…’ that wraps it. Then, further down, it’s writing this:

    $title_attr = esc_attr($post->post_title); //the_title_attribute('echo=0');
    		$grid_img = '<img src="' . esc_url($img_url) . '" alt="' . $title_attr . '" width="' . $nw . '" height="' . $nh . '" />';
    	 	$grid_img = '<a href="'. get_permalink() .'" title="' . $title_attr . '">' . $grid_img . '</a>';

    … so it’s putting its own permalink in. I’m not good enough at this to capture the original link and reinsert instaled of the ‘get_permalink()’ function (although I think I’m close) but is anyone else?

    Thread Starter Chris Billett

    (@chris-billett-2)

    Now thinking I need a preg_match to grab the hyperlink from the post, and then reinsert instead of ‘get_permalink()’ on the line:

    $grid_img = '<a href="'. get_permalink() .'" title="' . $title_attr . '">' . $grid_img . '</a>';

    Have tried and failed. Any input appreicated… although I get the feeling this is beyond most people judging from the amount of PHP experts who’ve banged their heads against it today.

    Thread Starter Chris Billett

    (@chris-billett-2)

    Solved this eventually with:

    preg_match('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $content, $matches);
    $captured_url = $matches[0];

    … before line 22 of the original functions.php – I obviously then replaced the later ‘get_permalink()’ with ‘$captured_url’

    Hi Chris,

    you mentioned using Shadowbox directly from the front page – I was hoping to achive the same thing, so when you click the image on the front page shaddow box open and show other images in that post? without ever having to enter the post page.

    Did you manage to achive this? Would love to know how if so!

    Cheers

    Dave

    Sorry forgot to mention I tried inserting the code that you solved your problem with eventually on line 22

    preg_match('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $content, $matches);
    $captured_url = $matches[0];

    but it did not work for me, was there something i missed?

    I have found the fix for this. its really simple just change the grid image link setting to false. see below.

    // [grid image link setting]
    $flg_img_forcelink = false;

    its also mention on the themes website (translated from japanise):

    To add an image pop-up system effects

    Lightbox2 プラグインなど、画像をポップアップ化するプラグインと併用できます。 Lightbox2 plugin and can be used with plug-in of images pop up. サムネイル画像に対して画像リンクが張られていれば、これらのプラグインを利用してポップアップ表示が可能になります。 If it is a link to the image thumbnail will pop up that can use these plug-ins. ただしメインインデックスで各グリッドに1つだけ表示される画像には、詳細ページへのリンクが強制的に張られます(画像へのリンクがあっても削除されます)。 The image displayed in each grid only one main index but are stretched to force the link details page (there will also remove a link to the picture.) そのためメインインデックスのグリッド内の画像もポップアップ化するには下記の指定を変更します。 To make the grid popup image in the main index therefore changes the specification below.

    <編集箇所:index.php> <Edits: index.php>

    [grid image link setting]の箇所、$flg_img_forcelinkをfalseに変更します。 [Grid image link setting] in place of, $ flg_img_forcelink change to false.

    $flg_img_forcelink = false; // add/overwrite a link which links to a single post (permalink).

    However this doesnt show the images in that post in lightbox, it instead shows the images on the front page!

    any help still appriciated!

    cheers

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Tanzaku permalinks on image grid’ is closed to new replies.