Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 69

RogueWave
Aspiring developer
Profile
Posts: 337
Reg: Jan 23, 2013
Park City
5,120
10/08/13 10:21 AM (12 years ago)

Custom HTML Plug-In Image Sizes

Building for IOS BT_v2.1.9. Xcode 5 I'm building an app for a friend and she wants it to work on iPhone 4 & 5, Retina, iPad and iPad mini. Her graphic artist has sent me 4 files of the same 91 images but different sizes. The images are "daily exercise cards" of varying sizes for each device. I'm using the Custom HTML plug in and hosting the images on my server. Below are three image links of the size issue I'm running into. (Too big for iPhone 4 and 5 and too small for iPad in the simulator.) The first image is the html code that I'm wondering if I can change so it will run all correct images for each device when called upon. The second image is how the image looks in the control panel and the last is a shot of the image and how it displays in the iPhone IOS 6.0 simulator. Core question: Is it possible to build for various sizes using one image with the Custom HTML plug in or should I defer to "one size fits all"? What do I resize then? The actual image or do I utilize proper HTML code to size the image correctly in the iFrame? 1. http://i.imgur.com/WYLx8sT.jpg 2. http://i.imgur.com/8oTRJD7.jpg 3. http://i.imgur.com/2aFoVie.jpg PS, I have minimal HTML experience, I follow patterns rather than principles at this point.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
10/08/13 10:33 AM (12 years ago)
So just a quick tip, I can't help on it all, but you CAN redirect to different pages with different sizes based on what device landed on the page. if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "http://google.com/myiphonepage.html"; } else { window.location = "http://google.com/myregularpage.html"; } FULL CODE HERE: http://pastebin.com/eW6Wqjsa So this code says, if the user comes to it with a iphone, to go to THIS LINK. Then you can add a ELSE statement that says if NOT, go to THIS OTHER LINK. So instead of resizing the image, just make 2 different pages with 2 different sizes and redirect the user to whichever page they should be looking at based on the device they come from. It can be a little inconvenient to do this since you need to keep two pages up to date, but it's definitely something you can look into if you don't get any other better answers. Cheers! David https://buzztouchmods.com/market
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
10/08/13 10:35 AM (12 years ago)
p.s. you can get different forms of detection codes here: http://davidwalsh.name/detect-iphone Cheers! David https://buzztouchmods.com/market
 
RogueWave
Aspiring developer
Profile
Posts: 337
Reg: Jan 23, 2013
Park City
5,120
like
10/08/13 10:44 AM (12 years ago)
Thank you, David, so this script goes into Xcode and the "window.location =" area is where I place the URL for my images. Cool, now I just need to know where to plug this line of code in and get it to work.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
10/08/13 10:46 AM (12 years ago)
No no! This script goes into your HTML page (so into the HTML source tab in the plugin html code settings). David https://buzztouchmods.com/market
 
RogueWave
Aspiring developer
Profile
Posts: 337
Reg: Jan 23, 2013
Park City
5,120
like
10/08/13 10:49 AM (12 years ago)
Ok, lol...Just checking. Learning curve is flattening ever so slightly. but window location = "My image url here" right?
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
10/08/13 11:10 AM (12 years ago)
No problem! No, that would be a web page link. So you make two html pages, both have different sized images. The code will send the user to the different page based on what device they are visiting from. David https://buzztouchmods.com/market
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
10/08/13 08:03 PM (12 years ago)
in the HTML for the image, try this, not sure if it will work, but validate in the Emulator: <img src="theURLofTheImage" width="100%" height="100%"> See if that takes an image for the iPad and autosizes it downwards for an iPhone. Let us know the results! -- Niraj
 
RogueWave
Aspiring developer
Profile
Posts: 337
Reg: Jan 23, 2013
Park City
5,120
like
10/09/13 07:57 AM (12 years ago)
Saweeet! Thank you, Niraj...works like a charm.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
10/09/13 08:11 AM (12 years ago)
Just be aware the iPad image is "heavier" in size for the iPhone. Which means the iPhone users will be waiting a bit longer for the image to download and appear on their devices. That may impact the user experience of "things just pop up onto the screen, blazing fast, very snappy and responsive!" Especially if you are downsizing images for Retina iPads! On second thought, I would not employ the given "shortcut" due to to the expected delays. -- Niraj
 
RogueWave
Aspiring developer
Profile
Posts: 337
Reg: Jan 23, 2013
Park City
5,120
like
10/09/13 08:13 AM (12 years ago)
Understood, fortunately, this is my first "Ad Hoc" distribution app to 7 people in an organization. I can make fixes along the way.
 

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.