1. #1
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    270
    Vote Rating
    1
    Answers
    11
    davisty is on a distinguished road

      0  

    Default Answered: Can I ajax images and keep in a store

    Answered: Can I ajax images and keep in a store


    Hello,

    Im wondering if I can ajax all of the images in a folder and then store them in a store?

    If this is possible does any one have any examples?

    Thank You

  2. To get all images from a directory you would need a server side script to get the directory contents. To return them in the Ajax call you would have to base64 the images into a string so it can be transported. This can then be kept in a store and even in localstorage if you wanted to as it's just a string at that point.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,656
    Vote Rating
    904
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    To get all images from a directory you would need a server side script to get the directory contents. To return them in the Ajax call you would have to base64 the images into a string so it can be transported. This can then be kept in a store and even in localstorage if you wanted to as it's just a string at that point.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha Premium Member dawesi's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia (aka GMT+10)
    Posts
    1,083
    Vote Rating
    44
    Answers
    24
    dawesi has a spectacular aura about dawesi has a spectacular aura about

      0  

    Default


    you can base64 them (aka turn them into a string) then request them and store them in a store.

    there's plenty of examples on the web of how to do that, you could even use src.sencha.io to do that for you from web accessible sources.
    Teahouse Training Company
    Official Certified Sencha Trainer

    Australia / New Zealand / Singapore / Hong Kong & APAC



    SenchaWorld.com - Sencha webinars, videos, etc
    SenchaForge.org - (coming soon)
    TeahouseHQ.com - Sencha ecosystem training portal

    Code Validation : JSLint | JSONLint | JSONPLint

  5. #4
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    409
    Vote Rating
    18
    Answers
    18
    digeridoopoo will become famous soon enough

      0  

    Default Carousel in examples....

    Carousel in examples....


    Don't forget about the image carousel example included with the framework, it's really useful as a reference...this loads pictures from a folder.

    I managed to adapt it so that when clicking on a particular item in my dataview (e.g. Thumbnail1) it loads the contents of folder 1 into a popup carousel.

    :-)

  6. #5
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    270
    Vote Rating
    1
    Answers
    11
    davisty is on a distinguished road

      0  

    Default


    Ok, I'll check it out. Thank Yall.

    Im setting up a slideshow. Ive got the effects part done, just didnt know how to get them.

    You guys are good.

  7. #6
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    409
    Vote Rating
    18
    Answers
    18
    digeridoopoo will become famous soon enough

      0  

    Default This is what I do...

    This is what I do...


    This is what I do....each thumbnail of my dataview has an id, foldername and number of carouselitems set in my model, so that when I tap it does the following:

    Code:
     var id = record.get('id');
            var foldername = record.get('foldername');
            var numberofcarouselitems = record.get('numberofcarouselitems');
            console.log(id);
            console.log(foldername);
            console.log(numberofcarouselitems);
    the rest of the code is taken from the picture carousel included with Sencha:


    Code:
    var categories = [foldername],
                itemsCountPerCategory = numberofcarouselitems,
                horizontalCarousels = [],
                items, i, j, ln, category;
    
    
            //now we loop through each of the categories
            for (i = 0,ln = categories.length; i < ln; i++) {
                items = [];
                category = categories[i];
    
    
                for (j = 1; j <= itemsCountPerCategory; j++) {
                    //and push each of the image as an item into the items array
                    //you can see we are using the img xtype which is an image component,
                    //and we just give is a custom cls to style it, and the src
                    //of the image
                    items.push({
                        xtype: 'image',
                        cls: 'my-carousel-item-img',
                        src: 'resources/images/' + category + '/' + j + '.jpg'
                    });
                }
    These items are then pushed onto my carousel. Hope it helps

    :-)