Recent Topics

1 Aug 07, 2008 19:07    

My b2evolution Version: Not Entered

I'm going to start heavily hacking the photoblog stuff. For example there is no way to get to the original full size photo. First I thought of simply building a link to it, but that would mean replacing the current browser window with an image. Functional, but ... yuck. Then I got fancy in my head and decided it'd be cool to link the resized image (with it's crappy name) to the original image and launch a popup that contains just an image. That way the visitor could actually access the real deal with the real deal name.

So anyway if someone knows the basics of building a link that will launch a popup window in b2evolution that'd be cool. Like how the file manager pops up when you click "files" while writing a post for example.

In a perfect world the title tag of the link will be something like "WWWW x HHHH, NNN kbytes, imagename" or something like that to give a bit of warning about what's gonna try to come down the pipe.

But first building a popup link the b2evo way would be way cool and I'm too lazy to figure that out so I can figure out how to hack in the automagic linking.

2 Aug 07, 2008 23:39

3264x2448 ยท 2.0 Мb

echo $File->get_image_size().' · '.$File->get_size_formatted()

Display a direct link to image

echo $File->get_url();

Get image width and height

$imgSize = $File->get_image_size( 'widthheight' );

Image thumbnail with pop-up link

echo '<a href="'.$File->get_url().'" title="'.
	$File->get_image_size().', '.number_format($File->_size / 1024, 1).' kb - '.$File->title.'"
	onclick="return pop_up_window( \''.
	$File->get_url().'\', \'popup_image\', '.($imgSize[0]+20).', '.($imgSize[1]+20).' )"><img src="'.
	$File->get_thumb_url( 'custom-70x70,80' ).'" alt="" /></a>';

3 Aug 08, 2008 03:16

Thanks!

um... I think you just took all the fun out of banging my head against a project ;)

4 Aug 08, 2008 03:55

:)

I use this code on one of my sites. I can also give you the function to get a File object by item ID

5 Aug 08, 2008 04:25

The function returns one image object for each item. The default mediaidx page doesn't allow you to break it on several pages and use prev/next links.

while( $Item = & mainlist_get_item() )
{
	$File = & get_File_by_Item_ID( $Item->ID );
	
	if( $File === false )
		continue;
	
	echo '<a href="'.$Item->get_permanent_url().'"><img
			src="'.$File->get_thumb_url().'" 
			alt="'.$File->title.'" 
			title="'.$Item->title.'" /></a>';
}

// Get File by Item ID
function get_File_by_Item_ID( $Item_ID, $file_number = 0 )
{
	$FileCache = & get_Cache( 'FileCache' );

	$SQL = & new SQL();	
	$SQL->SELECT( 'link_ID, link_ltype_ID, file_ID, file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc' );
	$SQL->FROM( 'T_links LEFT JOIN T_files ON link_file_ID = file_ID' );
	$SQL->WHERE( 'link_itm_ID = '.$Item_ID );
	$SQL->ORDER_BY( 'link_ID' );
	
	$Results = & new Results( $SQL->get(), 'link_' );
	$Results->query( false, false, false );

	$File = & $FileCache->get_by_ID( $Results->rows[$file_number]->file_ID, false, false );
	
	if( !is_object($File) && !$File->is_image() )
		return false;
	
	return $File;
}

6 Aug 08, 2008 09:25

Okay this is starting to work. The function you shared above is now in inc/files/model/_file.funcs.php because anywhere else I got a "there ain't no function like that" error. I see where the first code in your last post makes a thumbnail linked to a permalink page, which I'm sure has value ... but not to me right now.

With the first bit of code you shared I'm getting an error due to it doesn't know what $imgSize is, which is probably why my popup is so freakin tiny. Since I'll be linking to images that are larger than the average nuclear war I'll probably just hardcode a 480 by 320 size or something like that, but I'll play with stuff to see what there is to see. Maybe code it to the dimensions of the photoblog resize? Maybe in a perfect world this link won't even show up if the original isn't larger than the resized image?

Way better than no access to the original file though!

BTW are you aware of this problem and solution? http://forums.b2evolution.net/viewtopic.php?t=15660 For those using the photoblog feature/skin I think it will be very handy to know of. In fact since I am now a photoblogger I'd best hack my own core eh?

EDIT: fixed the name of the file I hacked this into ;)

7 Aug 08, 2008 11:44

The $imgSize variable is in my first post ;)
You can put this function in conf/_config_TEST.php


Form is loading...