Hello,
little code, big problems.
I want to open documents and images in a blank page using only Toolkit.
f::show($file_path);
works great with document (e.g. PDF), but not with images (nothing appears).
I also tried something like:
$img = New Media($image_path);
header::type(f::mime($image_path));
echo $img->read();
Same result.
Any ideas?
Thanks!
texnixe
September 26, 2017, 8:17pm
2
The media constructor takes two arguments, root and URL…
Ok, thank you!
But why this works:
$img = New Media($root,$url);
echo $img->html();
And this not?
$img = New Media($root,$url);
header::type(f::mime($root));
echo $img->read();
texnixe
September 26, 2017, 10:00pm
4
Are you trying this at the top of a blank page before any other code? Because this should work:
<?php
$img = new Media($root, $url);
$img->header();
echo $img->read();
?>
But only right before anything else is sent. Instead of using header and read, you can also use show().
Hum,
same result, works with documents, not with images:
This is the entire code of the page:
<?php
require('bootstrap.php');
$root = ROOT . get('f');
$url = URL . get('f');
if(f::type($root) == 'document'){
f::show($root); // this works
}else{
$img = New Media($root,$url); // this not
$img->show();
}
texnixe
September 29, 2017, 4:44pm
6
Hm, I can’t reproduce this.
What I did:
created a new test folder in htdocs (localhost)
copied a test image into it
installed toolkit as a subfolder
in that folder, created an index.php with the following content:
<?php
require('toolkit/bootstrap.php');
$root = '/users/sonja/htdocs/test/test.png';
$url = 'http://localhost/test/test.png';
if(f::type($root) == 'document'){
f::show($root); // this works
}else{
$img = New Media($root,$url); // this not
$img->show();
}
When I open this page, the image is displayed as expected. Hm…
Stupid mistake… (as usual :P). URL was wrong.
Now it’s works like a charm and the code can be simplified:
require('toolkit/bootstrap.php');
$root = ROOT . get('f');
f::show($root); // this works with images and documents
Thanks!!