Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Tagblitz adding normal_ to image URL when it shouldn't....  (Read 4919 times)

0 Members and 1 Guest are viewing this topic.

kvnband

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
Tagblitz adding normal_ to image URL when it shouldn't....
« on: August 04, 2006, 07:29:54 pm »

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
Code: [Select]
$thumb_url = get_pic_url($pic_data, 'thumb'); to
Code: [Select]
$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
« Last Edit: August 04, 2006, 09:57:20 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #1 on: August 04, 2006, 07:37:03 pm »

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.

Code: [Select]
    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.
Logged

kvnband

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #2 on: August 04, 2006, 07:41:59 pm »

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.
Logged

kvnband

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #3 on: August 04, 2006, 07:51:26 pm »

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
Logged

Nibbler

  • Guest
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #4 on: August 04, 2006, 08:33:04 pm »

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

kvnband

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #5 on: August 04, 2006, 08:37:06 pm »

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

Code: [Select]
<?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
Logged

thejake420

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 79
  • Jakes Jokes - the largest joke site on the web
    • Jakes Jokes
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #6 on: August 04, 2006, 08:55:34 pm »

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.)

Code: [Select]
if (strpos($normal_url,"_normal")!==false){
$editedstring = ereg_replace('_normal', "", $normal_url);
}


Jake

Nibbler

  • Guest
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #7 on: August 04, 2006, 09:51:29 pm »

You need to add

Code: [Select]
global $CONFIG;
in a new line below

Code: [Select]
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.
Logged

kvnband

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
Re: Tagblitz adding normal_ to image URL when it shouldn't....
« Reply #8 on: August 04, 2006, 09:56:17 pm »

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
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 21 queries.