Tagblitz adding normal_ to image URL when it shouldn't.... Tagblitz adding normal_ to image URL when it shouldn't....
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Tagblitz adding normal_ to image URL when it shouldn't....

Started by kvnband, August 04, 2006, 07:29:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kvnband

OK, I have downloaded the tagblitz plugin and modified it a fair bit to get it to do what I want.  I have changed it to ONLY show the bbcode box, and also to show the intermediate image instead of the thumbnail.  Now, the problem is that sometimes the images aren't large enough to have an intermediate image (http://www.eclecticdaydreams.com/dream/displayimage.php?album=537&pos=4) for example.  The bbcode box still adds normal_ to the image URL, thereby causing a broken < img > link. 

The code that I changed in order to show intermediate images instead of thumbnails was in the bbcode_add_data function.

I changed $thumb_url = get_pic_url($pic_data, 'thumb'); to $thumb_url = get_pic_url($pic_data, 'normal');

This change works perfectly on images that have an intermediate image, but doesn't work on ones that are small (like the avatar that I linked to)

Any help is much appreciated.
Kevin

Nibbler

It's the fault of your modifications, not the plugin itself. There is no logic inside get_pic_url() to check that the image exists in that size. Since thumbnails always exist that code is safe. Now you have changed it to 'normal' it is up to you to add the logic and decide which size you want. It's a little long winded though.


    if($CONFIG['thumb_use']=='ht' && $pic_data['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
      $condition = true;
    }elseif($CONFIG['thumb_use']=='wd' && $pic_data['pwidth'] > $CONFIG['picture_width']){
      $condition = true;
    }elseif($CONFIG['thumb_use']=='any' && max($pic_data['pwidth'], $pic_data['pheight']) > $CONFIG['picture_width']){
      $condition = true;
    }else{
     $condition = false;
    }

    if ($CONFIG['make_intermediate'] && $condition ) {
        $thumb_url = get_pic_url($pic_data, 'normal');
    } else {
        $thumb_url = get_pic_url($pic_data, 'fullsize');
    }


It may need further alterations to fit your code.

kvnband

I had just assumed that the logic was built into get_pic_url. 

I just started with coppermine, and I'm trying to get up to date on the variables that I can use and whatnot (didn't know what to use to view the pic height and width and compare it).....You did exactly what I wanted to, but didn't know how :)

Thanks.

kvnband

Well, crap.  That code is returning false all the time for some reason (again, I don't know the coppermine specific variables or what they mean)

The linking code is always generating the full sized image.......

Any help (again) is appreciated.
kevin

Nibbler

Please post the relevent code. Attach it to your post if it is too long to post.

kvnband

Here's what I've got in codebase.php

<?php
// ----------------------------------------------------------
// TagBlitz.com Plugin 1.0 for Coppermine Photo Gallery 1.4.6
// Copyright 2006 Jake Russell, All Rights Reserved
// ----------------------------------------------------------
//
// ----------------------------------------------------------
// Title: TagBlitz Plugin
// Version: 1.0 (stable)
// Author: Jake Russell - http://www.tagblitz.com
// Official Plugin Page: http://www.tagblitz.com/getcode.php
// Official Support Thread:
// Live environment test: CPG 1.4.6
// Tested with IE 6 and FF 1.5
// ----------------------------------------------------------
// 
// ----------------------------------------------------------
// AVAILABLE CUSTOMIZATIONS (Available, but not required!)
// If you prefer a text link instead of the TagBlitz button,
// simply change {$buttoncode} to {$linkcode}
// (Near line 154)
// ----------------------------------------------------------
//
// ----------------------------------------------------------
// THIS PLUGIN IS OFFERED "AS-IS" IN THE HOPE THAT IT WILL BE
// USEFUL. NO WARRANTY OR GUARANTEE WHATSOEVER IS STATED OR
// IMPLIED.
//
// You may freely distribute this plugin.
// ----------------------------------------------------------
// 
// ----------------------------------------------------------
// What does this plugin actually do?
// 
// This plugin provides two valuable services for your CPG:
//
// First, it gives your users the ability to easily share
// your CPG pages with over 50 different social bookmarking
// websites and services, including del.icio.us, Technorati,
// digg.com, Myspace, AIM, furl, and Blogger, just to name a
// few.
//
// Second, it gives your CPG the ability to produce cut and
// paste linking codes so your visitors can post thumbnail
// and text links to your pages all over the web.
//
// All the links are permanent URLs, of course.
//
// Frankly, this is the best promotional plugin in the world.
// ----------------------------------------------------------
?>

<script language="javascript" type="text/javascript">
<!--
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>
<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
include (
"{$CONFIG['ecards_more_pic_target']}/include/functions.inc.php");
// Create the BBcode with link to thumbnail 
$bbcodethumb_url get_pic_url($CURRENT_PIC_DATA'thumb');

// Add a filter
$thisplugin->add_filter('file_data','bbcode_add_data');
function 
bbcode_add_moredata($pic_data){ //$pic_data

$thumb_url get_pic_url($pic_data'thumb');
$fullsized_url get_pic_url($pic_data);
$normal_url get_pic_url($pic_data'normal');

$pic_data['html'] = $thumb_url.'<br>'.$fullsized_url.'<br>'.$normal_url.'<br>'.$pic_data['html']; 
return $pic_data//return $pic_data
}

function 
bbcode_add_data($pic_data){
include (
"{$CONFIG['ecards_more_pic_target']}/include/functions.inc.php");
// Set up variables to grab the picture title and absolute URL information
// Automatically grab and encode the Title
$title "{$pic_data['title']}";
$title urlencode($title);
// Automatically grab and encode the absolute URL
$url "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$url preg_replace('/\?(.*)/','',$url);
$linkingurl $url// Set a separate unencoder URL for use in the Linking Codes section
$url urlencode($url);
// Remove displayimage.php from $linkingurl for use in thumb url
$linkingurl2 $linkingurl;
$linkingurl2 preg_replace('/displayimage(.*)/','',$linkingurl2);
// Automatically grab and encode keywords, as defined in File Information section
$keys "{$pic_data['keywords']}";
$keys urlencode($keys);

//Define image URLs for linking codes

//Figure out whether to use the normal_ or fullsize image location depending on size
if($CONFIG['thumb_use']=='ht' && $pic_data['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
      
$condition true;
    }elseif(
$CONFIG['thumb_use']=='wd' && $pic_data['pwidth'] > $CONFIG['picture_width']){
      
$condition true;
    }elseif(
$CONFIG['thumb_use']=='any' && max($pic_data['pwidth'], $pic_data['pheight']) > $CONFIG['picture_width']){
      
$condition true;
    }else{
     
$condition false;
    }

    if (
$CONFIG['make_intermediate'] && $condition ) {
        
$thumb_url get_pic_url($pic_data'normal');
    } else {
        
$thumb_url get_pic_url($pic_data'fullsize');
    }


$fullsized_url get_pic_url($pic_data);
$downloadlink get_pic_url($pic_data'normal');
$normal_url get_pic_url($pic_data'normal');
// Set up the HTML template for the displayed data
$display_data =  <<<EOT
<strong>Forum Linking Code</strong><br>
<textarea style="background-image:url(http://www.eclecticdaydreams.com/talk/templates/Chronicles/images/gen_background.jpg)" onFocus="this.select()" name="bbt" cols="50" rows="1">[url=
{$linkingurl}?pos=-{$pic_data['pid']}][img]{$linkingurl2}{$thumb_url}[/img][/url]</textarea><br/>
EOT;
$pic_data['html'] = $display_data.$pic_data['html'];
return $pic_data;
}
?>

<?
// Additional notes
//
// v 1.0.1 - Fixed issue with incorrect thumb URL in inking codes.
?>


Kevin

thejake420

You might have to fiddle with this a little, but it should do the trick. (Check my syntax... I still make typos, and $normal_url might not be the proper variable to check... I haven't really mapped the code in this case. Maybe you'll have to check thumb_url or whatever for your particular needs, but the concept is the same.)


if (strpos($normal_url,"_normal")!==false){
$editedstring = ereg_replace('_normal', "", $normal_url);
}



Jake

Nibbler

You need to add

global $CONFIG;

in a new line below


function bbcode_add_data($pic_data){


so that you can read the config data. You should also enable debug mode with notices so that you can catch and fix errors when developing your code.

kvnband

Excellent...

Thank you nibbler.  Works beautifully.  And thanks for the tip about debug mode.  Coppermine isn't that hard to develop for...Makes me happy  ;D

Thanks again.
Kevin