Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 11    Views: 103

AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
08/04/15 08:20 AM (8 years ago)

Mac Image Gallery Bug

The Mac Image Gallery is only displaying 2 random pictures when I have about 20 added in, has this happened to anyone else?
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/04/15 08:33 AM (8 years ago)
Nope, just added it to my live app, because mosaic was giving me issues. Mac image gallery working great for me using 20-30 images per instance. Is there any pattern as to which ones it shows, like file extension or naming convention?
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
08/04/15 08:35 AM (8 years ago)
Im using .png with a url.
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/04/15 09:12 AM (8 years ago)
Hmmm, same here. Maybe it's something in the script that you're pointing the url to?
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
08/04/15 10:45 AM (8 years ago)
Ive tried all kinds of url's. It still isnt working
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/04/15 10:51 AM (8 years ago)
What do you mean all kinds of urls? You should just have the URL to the script on your server thats located in the same directory with your images. like http://www.myserver.com/images/myscript.php Your "myscript.php" script, or whatever you want to name it, should look something like this, and be placed in the same online directory as your images: <?php function fnCreateGuid(){ $RandomStr_1 = md5(microtime()); $RandomStr_2 = md5(microtime()); $randomString = substr($RandomStr_2, 4, 4) . substr($RandomStr_1, 0, 15); return $randomString; } //start the JSON output $JSON = "{\"childItems\":["; //it's assumed that this file is in the same directory as the images. Change imgDir if the images are elsewhere. $imgDir = "."; if(is_dir($imgDir)){ if($handle = opendir($imgDir)){ while (false !== ($file = readdir($handle))) { if(strlen($file) > 5){ //image files must end with .jpg, .jpgeg or .png $ext = substr(strrchr($file, '.'), 1); if(strtoupper($ext) == "JPG" || strtoupper($ext) == "JPEG" || strtoupper($ext) == "PNG"){ $JSON .= "\n{\"itemId\":\"" . strtoupper(fnCreateGuid()) . "\","; $JSON .= "\"itemType\":\"BT_imageItem\", "; $JSON .= "\"imageName\":\"" . $file . "\","; $JSON .=" \"imageURL\":\"http://www.mywebsite.com/images/" . $file . "\"},"; } } } } } //remove the comma after last image so JSON is valid $JSON = trim($JSON); if(substr(strtoupper($JSON), (strlen($JSON) - 1), 1) == ","){ $JSON = substr($JSON, 0, strlen($JSON) - 1); } //end the JSON $JSON .= "\n]}"; //print the output echo $JSON; exit(); ?>
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
08/04/15 10:55 AM (8 years ago)
Im using it on buzztouch so this should all be standard?
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/04/15 11:05 AM (8 years ago)
Oh, ok, I thought you were trying to use the dataurl field to point to images uploaded somewhere on the internet. If not, you need to leave the dataurl field empty. I've never tried uploading images directly through the plugin and using those (WAY too much data input for me), so maybe someone more familiar with that can chime in. The above is just how I use it to point the plugin to my images uploaded to my website, and it wouldn't matter if it's on the buzztouch server or your own self hosted server. I just point the dataurl to my online image directory and it fetches ALL images located in that directory, whether it's 1 image or 1,000 images, it populates all of them, with just having to add that one dataurl per screen.
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
08/04/15 11:06 AM (8 years ago)
man how do you do that without inputing them all manually?
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/04/15 11:13 AM (8 years ago)
see above. 1) copy the script above, paste it into a text editor 2) edit the line "http://www.mywebsite.com/images/" to where ever your images are going to be located 3) save it as "whateveryouwant.php" 4) upload this php file and your images to the same location somewhere online 5) in the screens control panel, for the dataurl, put "http://www.mywebsite.com/images/whatever.php" Done :) Now when going to that screen in your app, it will show every image thats located in that same online directory as the script. What I do, because my app has hundreds of photo sets, is I create directories on my website like AppName/Images/Photoset1 (and then Photoset2, etc), and just upload the php script to each directory, and I only have to change that one line in the php script to reflect the directory and reupload it to each photoset directory that I have. The I just have to put the dataURL in for each screen that I use, like "http://www.mywebsite.com/AppName/Images/Photoset1/whatever.php" or "http://www.mywebsite.com/AppName/Images/Photoset2/whatever.php", etc, etc
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
08/04/15 11:22 AM (8 years ago)
Awesome thanks for the tip.
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
08/04/15 11:30 AM (8 years ago)
No problem, let me know how it works out. Using DataURL's in Buzztouch is a total game changer. Unfortunately I don't know enough php to write my own custom scripts to use with the DataURL's, but I know people that do :)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.