for two days now, i have been looking for the correct place to put my local images and the correct way to access them in the Appcelerator platform (working with Alloy framework).
All i want to do is simply display a local image through an image view component. It works well with an image get from URL but seems impossible to get it from a local file.
this is an simple image view declaration in my index.js controller
/app/controllers/index.js. Where do i have to put my image to get this code working?
var img = Ti.UI.createImageView({
image:'images/DefaultIcon.png',
top:10,
width:100,
height:100
});
$.index.add(img);
I have read all the documentation about that issue and read a lot of similar questions over the internet. Anyway, none of the answers i've been reading bring me the correct solution.
No matter where i put my images into my project directory (assets folder, root folder, resource folder, image folder), those images seem to be not accessible !
I'm currently developing on iOS platform...
I really hope some of you guys have the solution ...!
Best regards,
Quentin
You need to put the images in the /app/assets/iphone/images folder.
Within that folder you can create as many folders as you'd like, the only thing you need to do is update the path accordingly.
So, you have an image with the name myIcon.png. Put this in /app/assets/iphone/images/myIcon.png (and don't forget to include #2x and #3x images in the same folder).
Then, in your imageView use this path /images/myIcon.png.
Want to put it in a folder? For example /app/assets/iphone/images/icons/myIcon.png then reference it in an imageview with /images/icons/myIcon.png.
For android you too need to use the images folder inside app/assets/android. But to specify dimension specific images you can put them in ldpi, mdpi,hdpi,xhdpi,xxhdpi and xxxhdpi folders as specified by Android
Related
I cannot find anything on the internet probably because I'm not sure how to ask the question properly, but I cannot seem to figure out why on some images or links to pages i have to put ../ in front of the file name for dreamWeaver to see the file. It's not every file just some of them.
It depends if the pages or images are in a separate folder.
If your page is in root/pages/home/index.html and your image is in root/pages/home/images/image.jpg then you will only need images/image.jpg but if the image is in root/pages/about/images/image.jpg then you require .. because it's outside of the local folder.
This is a good link: https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
I've searched high and low on stackoverflow and google for an answer to this question. Perhaps it's not possible, or I may need to devise a different method to do this.
In our iOS app we have a whole bunch of image sets in images.xcassets. But we're moving to a more dynamic environment where we'll be downloading image sets instead.
I'd like to try and stick with the convention of having everything in the images.xcassets folder. Except as said, I want to dynamically create the image sets based on the data we retrieve from our server. Is this possible?
So there is a way to do this, but it's iOS 8.0 and above. Unfortunately, we're supporting 7 and above so I can't use it.
But for anyone else who's interested, you can use the UIImageAsset class to do what you need to do when you want to create a container for your images to encapsulate different resolutions, as the images.xcassets container currently does.
UIImageAsset docs
This answer gives a good overview of the XCAssets folder at runtime: Can I access an xcassets directory on the filesystem? - it looks like it's the wrong way of going about things.
I believe it is recommended that you use the temp or document folders, depending on the how long you wish to keep these images (https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html).
i have a quick question and would really appropriate some advice.
i am trying to upload images to a directory held in in the view of a module.
the full link to the pic's directory in 'my member's module' is:
C:/Users/test/zend/testingZend2/module/Members/view/members/pics
however, the upload function is held in MembersController :
C:/Users/test/zend/testingZend2/module/Members/src/Members/Controller/membersController
i am able to upload images to the directory. however, i obviously don't want to use the full URL. i want to use a relative link.
i tried the relative links below but they don't work;
Members/view/members/pics
and
../../../view/members/pics
is there for example a function like dirname(DIR) that will provide the first half of the link to the pics directory.
thank you for your help
Paths are relative to the application root, so module/Members/view/members/pics should work.
I would question whether the view folder is a sensible place to store user-uploaded images. Images aren't views, and you won't be able to display these images easily since they are not in a public folder.
I have been told this is possible to do but cannot get this to work.
Basically I am trying to cache and image using forge.file.cacheURL()
Now I can get the file just fine and display it in the page by creating a new Image object but what I want to do is use this cached image to change the image in the topbar.
When ever I try to do it I get an error saying "file not found" and after reading the docs a little more it seems that trigger may have "src/" coded into the class because if I put just "image/logo.png" the logo.png will show up in the header because its part of the app package.
I guess the question is.. Is my assumption correct?
Thanks!
The native UI elements (topbar/tabbar) load images directly from your apps package, not through a URL in the same ways images are shown in the webview.
What this means is that currently you can only use images included in your app in the topbar/tabbar modules.
in case anyone is interested in this, the ability was added a while ago to the API so you can now use a cached image or filesaveURL feature of forge to change the header image dynamically.
Here are the approaches we tried but did not work
Version control the images - bloats up our git repo, not a good idea
Images on DropBox - Whenever our designer adds an image on Dropbox it gets available to engineers, but the engineers then have to add the new image to their Resources manually.
Image folder on DB, link folder under Resources - Same as above, but we add the folder under Resources, not the image files. However, the manual process of adding newly added images still remain.
What are the best practices you have followed?
Have you tried adding a Folder Reference instead of a group when adding it to your project and using DropBox to keep that folder up to date with your images ?
As a Folder Reference, it should always reflect the current state of the linked folder without the need to manually add each file as it is downloaded from DB.
After running a quick test, I found that adding Folder References and trying to use the images from there with [UIImage imageNamed:#"fileName.png"] doesn't find the actual image.
You have to actually include the relative path to your Folder Reference, like this:
UIImage * imageFromFolderReference = [UIImage imageNamed:#"FolderReferenceName/fileName.png"];
That seemed to do the trick.