Starting a iPhone Theme

Hello everyone,

Today I started creating a iPhone Theme for zenphoto. I use zenphoto on my website, but I wanted to have a theme specially to view my galleries from my iPhone. I'm not really good in scripting and creating, but I will do my best to make it better step by step.

I would like to here from you what you think of it (and of the idea). You can follow it step by step at this topic and you can download some beta versions of the theme at:
http://mirror.nielshoogenhout.nl/index.php?dir=./Scripts/zenphoto+iPhone+Theme/

I really just started it, so don't expect to much of it. It isn't a clean script, the datatraffic isn't reducing at the moment, but every thing works at the moment.

Niels

(Thanks to iWebKit.net & the Example Theme from Tristan Harward!)
«13

Comments

  • Not sure if it's possible... but an ideal scenario would be to have browser recognition to switch the theme on the fly.
  • Cool! On the topic of switching themes on the fly, here's how other sites recognize iphones and switch with javascript:

    `

    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location =
    "http://m.espn.go.com/wireless/?iphone&i=COMR";
    }

    `
    Clearly this is from espn but I think the same idea could work for zenphoto maybe?
  • Hello CMNYC,

    It is possible to do so, and i definitely will put that on my own site. The only thing you need to do is put a little code into the zenphoto index file. By the next update I will explain every one how they can easely do this themselve.

    Maybe in a later stadium i will try to create an plugin that you can install to do this for you. But before I can do this I should have a look at the scripting from zenphoto. I never did this before.

    Niels

    *//Edit @pedroserano: That is one way to do so, maybe I will implemented it to all the mobile phone types. Because when the theme is iPhone optimized, it would probably be better for other phones aswell. (btw. The example you use can not be used for zenphoto the way you placed it here. Because you would need a double installation of zenphoto, and that is not what we want, is it. I will give the solution i think is best as soon as possible).
  • V0.3 Beta (http://mirror.nielshoogenhout.nl/index.php?dir=./Scripts/zenphoto+iPhone+Theme/)
    Updates:
    - A little bit cleaner code (not finished!)
    - A nice header on top of each page (execept the image page because of the smaller screen the iPhone has, there won't be a lot of space for the image left).
    - In the gallery pages the standard thumbs will be used.
    - On the image page a speciale iphone image will be generated. The size is optimalized for the iphone. This wil reduce the data traffic, and also speeds up loading the image. (The image is saved in the cache directory like the other pictures).

    Future:
    - Wil clean up the code so it will be easier to understeand for every one.
    - I would like to hear from you what you would like to see in the theme.
    - Choosing if you want to show images on the gallery pages, yes or no.
    - I wil try to speed up the theme by cleaning out the code. The reason why the pages will never load very quick is because of 2 reasons. 1. zenphoto isn't created for mobile phones, I can only work on a better optimized theme. 2. A lot of pictures needs to be loaded every time.
  • Here's a link to have ZP automatically choose the theme based on whether you're using a mobile device: (pays to look around the forum)

    http://www.zenphoto.org/support/topic.php?id=3788

    With the new ZP, instead of opening index.php, go to functions.php and follow the instructions for replacing:
    `$theme = $_zp_gallery->getCurrentTheme();`
  • Anyone still working on this? It would be great to have a complete iPhone theme!
  • Has anything come of this?
  • Hi acrylian,

    If you're checking up on this forum, I wanted to share that I've almost completed an iPhone theme. Its realativly basic, but its a start. I'd love some feedback about its function and utility. It was very easy to tie your functions into the iPhone view. It really says something about the way you've designed everything, very nice.

    I thought if I could post it somewhere others would be able to improve upon what I've started. Do you host the themes or should I look into hosting elsewhere (any suggestions)? Let me know if you'd like more info, I'd be happy to share what I've got going. Thank you!
  • acrylian Administrator, Developer
    Of course I check the forum..;-) Surely interessting news for some of our users.

    We would actually prefer if you set up your own project page for that theme because we of course can't support third party themes (or any other third party stuff). If you did that let us know and we add an entry with some screenshots on our themes page linking to that page. Best in this case you provide screenshots on your page we can also use as I personally don't have any internet capable mobile.
  • where can we find this iphone theme! ill help you work on it if you want :-)
  • I've just been putting some finishing touches on it. The sorts of things I wanted it to do. I would LOVE for you (and others to improve and make it better). I will post here once I'm finished and have a tar file ready. You can expect to see it this afternoon.
  • acrylian,

    I'm redirecting automatically to the iphone theme, as discussed in this thread, by modifying functions.php.

    I'd like to set the image_quality and thumb_quality to lower values for the iPhone theme only; to ensure faster rendering times.

    Using `setOption("image_quality",50,true);` works, but also changes the quality for the main theme. This has been discussed elsewhere in this forum. Unfortunately, according to the theming documentation (http://www.zenphoto.org/2009/03/theming-tutorial/#override-options) the scripts which get called up later are not effected by non-persistent settings, and so the template-functions.php use the global settings and the images are rendered at normal quality.

    Is there a way to set these values without $persistent being set to True? Thanks for your assistance!
  • Hi, scratch that last question. I modified the functions-basic.php with the following:

    `
    function getImageParameters($args) {
    //set specifics if iphone detected
    $UA = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
    $iphone = stristr($UA, 'iPhone') ? true : false;
    if($iphone){
    setOption("image_quality", 70,false);
    setOption("thumb_quality", 60,false);
    }
    `
    Works great.
  • This raises another question, which applies to any theme. It appears that ZenPhoto does not currently differentiate between thumbnail quality and image quality. It generates both of the image types using the settings for image_quality. If I force (or set in the admin console) the quality of regular image to 100, and thumbnail to 0, everything renders at 100%.

    Any thoughts?
  • I have not been following this thread, so forgive me if I have missed something. But it is really not a good idea to hack the Zenphoto core as you describe above. Pretty much makes the theme unusable by most Zenphoto users.

    Is the iPhoto theme a specific theme? Sounds like it is since you say you redirect to it. If so, then you should be putting these non-persistent option settings in the theme itself. The easiest way to do this would be to have a theme custom function that is called from each theme page that does this setting.
  • It will use the thumb_quality for standard thumbnails. But if you are using custom image functions to generate the thumbnails, they will use the image_quality.
  • I can understand why it is undesirable to modify any piece of the core; however this particular change does not effect any of the regular function (unless the agent is determined to be an iPhone. Here is the part it effects:

    `
    $UA = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
    $iphone = stristr($UA, 'iPhone') ? true : false;
    if($iphone){
    setOption("image_quality", 70,false);
    setOption("thumb_quality", 50,false);
    }

    $thumb_quality = getOption('thumb_quality');
    $quality = getOption('image_quality');
    $thumb_crop = getOption('thumb_crop');
    $thumb_size = getOption('thumb_size');
    $thumb_crop_width = getOption('thumb_crop_width');
    $thumb_crop_height = getOption('thumb_crop_height');
    $image_default_size = getOption('image_size');
    `
    So essentially, it is just like having two sliders in the admin panel for image_quality and two for thumb_quality, one for the default theme and one for the custom theme.

    The reason this seems necessary is that the non-persistent setting for this particular property does not work, it only effects the current function, not those that get called up to do the actual custom image creations. Of course, persistent do work but they change the options for all themes.

    If there is another way, please let me know.

    ----

    As far as the thumb_quality property not being used for custom thumb image functions, is there any way around this? This isn't a big deal, if not.
  • I have posted the first (very preliminary) version at the following page:

    http://code.google.com/p/zenphotoiphone/

    Please try it out and tell me what you think. There is a lot that can be approved upon, so please do if you have the ability. I'm excited to see where this goes.

    There are also some screenshots:
    http://code.google.com/p/zenphotoiphone/wiki/ScreenShots

    I will post some more info there in the coming days.
  • acrylian Administrator, Developer
    I have no time currently to look at the theme itself (do not have a mobile device to test at all actually). But you can make your own theme specific options that can be independent from the general ones. All you have to do is to use our "custom image" functions as sbillard suggested and use the values of the theme options with them.
  • I will look into that this evening. Does it still apply the settings when the theme is not 'active'? (remember, I'm redirecting iPhone only to this theme in functions.php).

    If you find some time, you can always view it in firefox... It just won't be formatted exactly like in iPhone safari.
  • I have fixed the problem with the custom thumbs in the nighty builds.

    It is not so much that your code might or might not have an impact on a standard theme that suggests you should not hack the core. It is that for someone else to use your theme they also must hack the core. They might not be so tallented or attentive to change as you. And, of course, if they do not do it or don't do it correctly, you will be getting the questions of "Why does this not work for me?"

    Much better to place the code into the theme where it will always be there.
  • The "non persistent" setOption is good only for the duration of the script that calls it. No change is made to the database.
  • Also, in tonight's build there will be a new filter for you to use to redirect your theme. attach to the `setupTheme` filter. It will be passed one parameter--$theme which is the currently selected theme. Simply return your iPhone theme name if the viewer is on an iPhone.

    This will not be the place to set the options as option handling setup gets done after the theme is determined.
  • Thank you gentlemen. This is excellent!

    With regards to hacking the core, you make an excellent point that I had not considered. I won't be advising anyone to do that. :)

    Perhaps I'm being daft, but I cannot seem to figure out how to set a theme specific image_quality setting anywhere. 'i.php' calls 'functions-basic.php' during the creation of a custom photo, and so it grabs the global image_quality setting, overriding any earlier attempt to non-persistently configure it. Configuring a themeoptions.php file only serves to change the global settings for image_quality.

    Regardless, this is not a major requirement. I think that one global setting should be sufficient for most.

    I've finished putting together the project page for the theme. I'd be honored if you would consider displaying it in your theme gallery. Thanks for your amazing application!

    http://code.google.com/p/zenphotoiphone
  • acrylian Administrator, Developer
    Great, I will take a look and then add the theme to our themes page later.

    Regarding the image quality: You can also use i.php directly to generate images instead of using the custom image functions or class methods. These are acually wrappers. Then you can set the quality parameter directly.
  • acrylian Administrator, Developer
    I have added it and wrote also a post on our news section.
  • To anyone who is interested, I've posted an update to this theme with some fixes and improvements.

    http://code.google.com/p/zenphotoiphone/
  • Actually, i.php will grab the options from the current theme which may be an album theme. Maybe it does not pick up the theme returned from the filter. When I get back from vacation I can check into that.

    But it certainly will not pick up a temporary option as it is a new run of the script, so I guess you will have to deal with that and cause the quality to be selected at the call on the custom image functions.
  • That doesn't work, because it ends up collecting the global setting for the currently selected theme. The only way I've found to work (posted above) involved editing the core, which I'm not going to recommend to anyone :)

    This isn't a big deal. I think everyone is fine with one global setting for image quality. I certainly am.
  • Build 4465 has implemented early binding of image processing parameters. This should allow you to have your iPhone theme do non-persistent option settings and use the standard functions to create you image links.
Sign In or Register to comment.