How to get image URL of a Concrete5 website from an external php file
Permalink
Hello,
I'am supposed to create a mobile version of a Concrete5 website which will automatically search the images displayed on the website from the database and then display them on the mobile version. I successfully done that but found out that the only info stored on the db about the images are their fID. I found that in order to use this to get the images i need to use some functions that are from Concrete5 which are Loader::model('file_set'); and Loader::model('file_list');
However since my file is outside Concrete5 i cannot use these i thought of some include .php file that i would place into the Concrete5 website which would get the URLs into a variable via a function but it doesn't seems to work. Is that even possible?
Thanks
I'am supposed to create a mobile version of a Concrete5 website which will automatically search the images displayed on the website from the database and then display them on the mobile version. I successfully done that but found out that the only info stored on the db about the images are their fID. I found that in order to use this to get the images i need to use some functions that are from Concrete5 which are Loader::model('file_set'); and Loader::model('file_list');
However since my file is outside Concrete5 i cannot use these i thought of some include .php file that i would place into the Concrete5 website which would get the URLs into a variable via a function but it doesn't seems to work. Is that even possible?
Thanks
Hello, thank you for the answer.
so i need to put the first code in a file themes/mytheme/tools/img_search.php is that right?
As for the line i'am supposed to post in the external file, where should i post it? Is there like a special Concrete5 tags or something because it is not recognized since it is pure php file and don't understands Concrete5 yet
so i need to put the first code in a file themes/mytheme/tools/img_search.php is that right?
As for the line i'am supposed to post in the external file, where should i post it? Is there like a special Concrete5 tags or something because it is not recognized since it is pure php file and don't understands Concrete5 yet
Are you using 5.6 or 5.7, this will NOT go in your theme either way, but depending which one you are using it will go in a different place and the syntax might be different. This code is for 5.6
The version i'am using is 5.6.3.1
So you would put the first chunk of code into the /tools directory as get_image_url.php then on your 3rd party page you would just put that code into the img src attribute and it will load the image to it
Hello, thanks for the help.
However i have still a problem since it is not working i'am including the get_image_url.php page via <?php include('relative_path/get_image_url.php'); ?>
but this gives me an "Access denied".
as for the images here is the problem i put my code in the image search as you told but it give me an error as it is not recognised by the php. Here is the code.
<img src="<?php {{ $c5_url }}/tools/get_image_url?fileID={{ $fID }} ?>" height="100" width="100">
thanks
However i have still a problem since it is not working i'am including the get_image_url.php page via <?php include('relative_path/get_image_url.php'); ?>
but this gives me an "Access denied".
as for the images here is the problem i put my code in the image search as you told but it give me an error as it is not recognised by the php. Here is the code.
<img src="<?php {{ $c5_url }}/tools/get_image_url?fileID={{ $fID }} ?>" height="100" width="100">
thanks
When you put the code on your page you replaced the items in the double curly brackets with the actual values, right?
Also, what is the error?
And you can't include C5 scripts from outside of C5 like that, it won't work.
Also, what is the error?
And you can't include C5 scripts from outside of C5 like that, it won't work.
yes in the first bracket i put the relative path to get_image_url.php in the "tools" directory and in the second one i put $row['fID'] isnt it what i should do?
In the first bracket you need to put the C5 URL, not a path and not relative. It should look likehttp://www.website.com
but i cannot for security reason try to access the website's pages from an external page. I already tried with the inclide and had my files put in quarantine for being seen as a malware and had to call the support center in order to explain them the situation and they told me i should only use relative paths. I dont feel like doing it again. Is there a solution. The people only gave me the FTP, Concrete5 and DB access to their website.
If you can't access the site via URL then this solution will not work and I apologize, but I can't help.
hello,
Sorry but i have another question.
So now i created a block containing my view file so that when the user add a block and manually enter a number, it will search in the database for the bID corresponding to that number and display the title of that image and hopefully it will also display the image.
In order to do so i tried again your code so here is the question because i'am not sure of doing it right
so in the part:
{{ $c5_url }}/tools/get_image_url?fileID={{ $fID }}
I put
<img src="http://www.mywebsite.com/tools/get_image_url.php?fileID=<?php $row['fID'] ?>" />
isnt it the correct way to do it? because it dont seems to work :(
Thanks
Sorry but i have another question.
So now i created a block containing my view file so that when the user add a block and manually enter a number, it will search in the database for the bID corresponding to that number and display the title of that image and hopefully it will also display the image.
In order to do so i tried again your code so here is the question because i'am not sure of doing it right
so in the part:
{{ $c5_url }}/tools/get_image_url?fileID={{ $fID }}
I put
<img src="http://www.mywebsite.com/tools/get_image_url.php?fileID=<?php $row['fID'] ?>" />
isnt it the correct way to do it? because it dont seems to work :(
Thanks
I finally did it!
Here is how i did it if someone is interested
Here is how i did it if someone is interested
<?php $im = Loader::helper('image'); $query = "SELECT caption, fID FROM myGallery WHERE bID='$content'"; $res = mysql_query($query); if (!$res) { die('Invalid query: ' . mysql_error()); } while($row=mysql_fetch_array($res)) { $fID = $row['fID']; $file = File::getByID($fID); $thumb = $im->getThumbnail($file, 500, 300); echo "<table>"; echo "<tr>"; echo "<td>"; ?> <img src="<?php echo $thumb->src ?>" /> <?php echo "</td>";
Viewing 15 lines of 20 lines. View entire code block.
Then in your outside application just call something like this, and it will return the URL