Retrieving Content/Image handle - A technical question

Discuss phpwcms here, please do not post support requests, bug reports, or feature requests! Non-phpwcms questions, discussion goes in General Chat!
Post Reply
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Retrieving Content/Image handle - A technical question

Post by jsw_nz »

I am trying to figure out how phpwcms retrieves the content/image handle, since I have a custom requirement to display an article(in list format) from another section of site. I understand that the primary data for a given article is found in phpwcms_article table and that the image info is serialized in the binary blob format in the article_image column. When I unserialized it, it returns an array ($image_array) and by running this code:

Code: Select all

foreach ($image_array as $key => $value){echo $key.' is '.$value.'<br>';}
I get these fields:

tmpllist is 'aVariable'
tmplfull is 'aVariable'
name is 'aVariable'
id is 'aVariable'
width is 'aVariable'
height is 'aVariable'
caption is 'aVariable'
zoom is 'aVariable'
hash is af4297ff9d6ab81c26f845f1bc8141b6
ext is gif

My queston is about the hash, which references the original image in file manager, which is stored in filestorage directory. Where in wcms is the reference to that 'sized' image that is located in the content/images folder for any given article. Is there another embedded array in this serialized object? I did a export of entire DB, and did a text search for the final sized image handle, (which is located in content/images/)

974aa60d59f8dbb0a8bd3579993cc0b7

and found it in the phpwcms_cache table. Is this the only place where a reference to the image is stored? If so it would be difficult to retrieve it programmatically.

So I guess this is a technical question, just wanting to know where wcms pulls data to display the sized image from content/images folder...or perhaps it does not, but rather gets it exclusively from phpwcms_cache table......but that would be strange however, since the full article is cached, not just the summary listing.....

Cheers,
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

if you want to get those vars you can also use

echo '<pre>';
print_r($var);
echo '</pre>';

The hash references a file - see the phpwcms_file. Hope this is the answer you need.

In total the reference hash for an image is a special MD5 encoded string based on size and quality and file's hash. See the content parts in whcih images are created.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Post by jsw_nz »

Thanks Oliver,
Was able to follow your pointers to retrieve the actual image handle. Apparaently it is the get_cached_image() function that does the trick. The basic idea (primitive at this stage) is to pull up an article listing anywhere within Wcms. (I have a situation where administrator has disallowed allow_url_fopen() so essentially the {URL:index.php?myArticle} would not work. Here is what I managed to draw from your existing code so far (my version very simplified):

Code: Select all

$specific_article = mysql_query("SELECT * FROM phpwcms_article WHERE article_id = '$whichArticle'");
$article = mysql_fetch_row($specific_article);
//$article_title=$article[6];
//$article_subtitle=$article[13];
//$article_summary=$article[14];
$article_image=$article[19];
$image_array=unserialize($article_image);
$thumb_image = get_cached_image(
	array("ext" =>$image_array['ext'],
	"hash" =>	$image_array['hash'] . '.' . $image_array['ext'],
	"width"=>$image_array['width'],
	"height" =>$image_array['height'],
	"thumb_name" =>md5($image_array['hash'].$image_array['width'].$image_array['height'].$GLOBALS['phpwcms']["sharpen_level"])
	));
?>
//display actual image from content/images folder
<?php echo '<img src="content/images/'.$thumb_image[0] .'" border="0" '.$thumb_image[3].'>';?>
At least for purposes of being a hack it works (partially). All I need to do is to display one article on the home page (based on the day of the week) and use a redirect on the link to go to this section, displaying all seven days. I imagine there is a far more elegant way to pull all stuff together (tmpllist & full article link)....if so it might be a nice replacement tag [INC_ARTICLE_LISTING:NUM] allowing the display of an article listing anywhere inside Wcms, thus by passing the need of using {URL:...} tag.

Thanks.... :)
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

something I have in preparation...

but for now use custom block and content part article link/menu.
does not work in article listing mode.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Post Reply