1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Image Manager Bugs

Discussion in 'PHP' started by Jeremy Benson, Jul 9, 2014.

  1. #1
    Hey,

    I'm working on an image manager, but I can't seem to add photos to an existing album. I've got this one function that creates an album if it hasn't been created, and one that should fire if the user is trying to add photos to an existing album. The problem is I seem to always end up in the function that creates an album. I've got a block in there that sends the user back to their dashboard if the album already exists(I'll take that out after).. That's what keeps happening.

    As far as I can tell I keep ending up in that first block in the last if statement.

    PHP:
    1.  
    2. if($_POST['editType'] == "managephotos")
    3. {
    4.  
    5.    $albumName = $_POST['albumName'];
    6.    $retrievedInfo = [];
    7.  
    8.    //Count the amount of name elements there are in $_FILES
    9.  
    10.    $limit = count($_FILES['imageFiles']['name']);
    11.    
    12.    $fileHelper = new cfile;
    13.    $fileHelper->process_files($_FILES, $limit, "img");
    14.  
    15.    //Test if album name exists if it exists add photos else create album
    16.    $dbConnect = new cdbconnect;
    17.  
    18.    $dbConnect->select("SELECT `albumName` FROM `photoalbums` WHERE `userName` =  ? AND `albumName` = ?", [$albumName, $user->return_username()]);
    19.    $retrievedInfo = $dbConnect->get();
    20.  
    21.    if(empty($retrievedInfo) || $retrievedInfo[0] == "")
    22.    {
    23.      $fileHelper->make_photoalbum($albumName);
    24.  
    25.    }else{
    26.  
    27.      //update album.
    28.    
    29.      $fileHelper->update_photoalbum($albumName);
    30.  
    31.    }
    32.  
    33. }
    34.  
     
    Jeremy Benson, Jul 9, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Well-Known Member

    Messages:
    1,750
    Likes Received:
    175
    Best Answers:
    64
    Trophy Points:
    160
    #2
    Uhm, try switching around $albumName and $user->return_username() in the query...
     
    PoPSiCLe, Jul 10, 2014 IP
  3. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    That was such a stupid bug. I found that when I got home, but there's one other thing that isn't working.
     
    Jeremy Benson, Jul 10, 2014 IP
  4. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #4
    That bug was dumb. I found it when I got home, but there's another giving me some trouble. Not sure if I can find this one... I've got an onclick function on a div that opens the photo album when clicked, and changes photos. Right now when I click the album all the pictures show alternate text.

    The following javascript function calls the php script below.

    Code (Javascript):
    1. function change_photoalbum(IDSet)
    2. {
    3.  
    4.     var id = IDSet;
    5.    
    6.     var idData = {"IDSet":id, "from":"dashboard"};
    7.    
    8.     var output = Array();
    9.    
    10.     $.ajax({
    11.         "type":"POST",
    12.         "url":"../mechanics/scripts/php/getphotoalbum.php",
    13.         "dataType":"html",
    14.         data:idData,
    15.         "success":function(data){
    16.        
    17.             output = data.split(',');
    18.            
    19.             window.document.getElementById('albumnameoutput').innerHTML = (output[1]);
    20.             window.document.addalbumform.albumName.value = (output[1]);
    21.            
    22.             window.document.getElementById('albumimage1').innerHTML = "";
    23.             window.document.getElementById('albumimage2').innerHTML = "";
    24.             window.document.getElementById('albumimage3').innerHTML = "";
    25.             window.document.getElementById('albumimage4').innerHTML = "";
    26.             window.document.getElementById('albumimage5').innerHTML = "";
    27.             window.document.getElementById('albumimage6').innerHTML = "";
    28.             window.document.getElementById('albumimage7').innerHTML = "";
    29.             window.document.getElementById('albumimage8').innerHTML = "";
    30.             window.document.getElementById('albumimage9').innerHTML = "";
    31.             window.document.getElementById('albumimage10').innerHTML = "";
    32.             window.document.getElementById('albumimage11').innerHTML = "";
    33.             window.document.getElementById('albumimage12').innerHTML = "";
    34.            
    35.             if(data != "")
    36.             {
    37.                 alert(data);
    38.                
    39.                 if(output[2] != "")
    40.                 {                                                              
    41.                     window.document.getElementById('albumimage1').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[2] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[2].substring(0, output[2].indexOf('.')) + "_tmb" + output[2].substring(output[2].indexOf('.'), output[2].length) + "\" />";
    42.                 }
    43.                 if(output[3] != "")
    44.                 {
    45.                     window.document.getElementById('albumimage2').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[3] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[3].substring(0, output[3].indexOf('.')) + "_tmb" + output[3].substring(output[3].indexOf('.'), output[3].length) + "\" />";
    46.                 }
    47.                 if(output[4] != "")
    48.                 {
    49.                     window.document.getElementById('albumimage3').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[4] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[4].substring(0, output[4].indexOf('.')) + "_tmb" + output[4].substring(output[4].indexOf('.'), output[4].length) + "\" />";
    50.                 }
    51.                 if(output[5] != "")
    52.                 {
    53.                     window.document.getElementById('albumimage4').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[5] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[5].substring(0, output[5].indexOf('.')) + "_tmb" + output[5].substring(output[5].indexOf('.'), output[5].length) + "\" />";
    54.                 }
    55.                 if(output[6] != "")
    56.                 {
    57.                     window.document.getElementById('albumimage5').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[6] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[6].substring(0, output[6].indexOf('.')) + "_tmb" + output[6].substring(output[6].indexOf('.'), output[6].length) + "\" />";
    58.                 }
    59.                 if(output[7] != "")
    60.                 {
    61.                     window.document.getElementById('albumimage6').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[7] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[7].substring(0, output[7].indexOf('.')) + "_tmb" + output[7].substring(output[7].indexOf('.'), output[7].length) + "\" />";
    62.                 }
    63.                 if(output[8] != "")
    64.                 {
    65.                     window.document.getElementById('albumimage7').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[8] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[8].substring(0, output[8].indexOf('.')) + "_tmb" + output[8].substring(output[8].indexOf('.'), output[8].length) + "\" />";
    66.                 }
    67.                 if(output[9] != "")
    68.                 {
    69.                     window.document.getElementById('albumimage8').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[9] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[9].substring(0, output[9].indexOf('.')) + "_tmb" + output[9].substring(output[9].indexOf('.'), output[9].length) + "\" />";
    70.                 }
    71.                 if(output[10] != "")
    72.                 {
    73.                     window.document.getElementById('albumimage9').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[10] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[10].substring(0, output[10].indexOf('.')) + "_tmb" + output[10].substring(output[10].indexOf('.'), output[10].length) + "\" />";
    74.                 }
    75.                 if(output[11] != "")
    76.                 {
    77.                     window.document.getElementById('albumimage10').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[11] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[11].substring(0, output[11].indexOf('.')) + "_tmb" + output[11].substring(output[11].indexOf('.'), output[11].length) + "\" />";
    78.                 }
    79.                 if(output[12] != "")
    80.                 {
    81.                     window.document.getElementById('albumimage11').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[12] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[12].substring(0, output[3].indexOf('.')) + "_tmb" + output[12].substring(output[12].indexOf('.'), output[12].length) + "\" />";
    82.                 }
    83.                 if(output[13] != "")
    84.                 {
    85.                     window.document.getElementById('albumimage12').innerHTML = "<img height=\"120\" width=\"90\" alt=" + output[13] +" src=\"users/"+ output[0] +"/images/albums/" + output[1] + "/" + output[13].substring(0, output[13].indexOf('.')) + "_tmb" + output[13].substring(output[13].indexOf('.'), output[13].length) + "\" />";
    86.            
    87.                 }      
    88.             }
    89.         }
    90.     });
    91. }
    92.  
    PHP:
    1.  
    2. <?php
    3.  
    4.    require('../../../mechanics/data/sqldata.php');  
    5.    require('../../../mechanics/scripts/classes/php/cdbconnect.php');
    6.      
    7.    $albumID = $_POST['IDSet'];
    8.    $albumName = "";
    9.    $retrievedInfo = [];
    10.    $totalViews = 0;
    11.    
    12.    $returnString = "";
    13.    
    14.    $dbConnect = new cdbconnect;
    15.    $dbConnect->select_all("SELECT `userName`, `albumName`, `photo1name`, `photo2name`, `photo3name`, `photo4name`, `photo5name`, `photo6name`, `photo7name`, `photo8name`, `photo9name`, `photo10name`, `photo11name`, `photo12name`, `albumViews` FROM `photoalbums` WHERE `ID` = ?", [$albumID]);
    16.    
    17.    $retrievedInfo = $dbConnect->get_all();  
    18.    
    19.    //Update views
    20.    if($_POST['from'] != "dashboard")
    21.    {
    22.    
    23.      $totalViews = $retrievedInfo[0]['albumViews'] + 1;
    24.    
    25.      $dbConnect->update("UPDATE `photoalbums` SET `albumViews` = ? WHERE `ID` = ?", [$totalViews, $albumID]);
    26.    
    27.    }else{
    28.    
    29.    
    30.      $totalViews = $retrievedInfo[0]['albumViews'];
    31.    
    32.    }
    33.    
    34.    //Send information back to profile.
    35.    
    36.    for($i = 0; $i <= 13; $i++)
    37.    {
    38.    
    39.      $returnString = $returnString . $retrievedInfo[0][$i] . ',';
    40.    }  
    41.    
    42.    $returnString = substr($returnString, 0, strlen($returnString) - 1);
    43.    
    44.    echo $returnString;
    45.  
    46. ?>
    47.  
     
    Jeremy Benson, Jul 10, 2014 IP
  5. PoPSiCLe

    PoPSiCLe Well-Known Member

    Messages:
    1,750
    Likes Received:
    175
    Best Answers:
    64
    Trophy Points:
    160
    #5
    Hard to say, but that javascript function really should use a loop - there's a lot of unnecessary code in that callback. Check to see what gets returned via Firebug, or similar, and see if there is anything wrong with the input that's supposed to get parsed in the output.
     
    PoPSiCLe, Jul 10, 2014 IP
  6. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #6
    Not sure what you mean by using a loop... lol, I hear things, but don't really know what is meant... The string returned by the php script is as follows...

    Famous4, test2, jeremy.jpg, DarkFoil.jpg, BlackandWhiteSticker - Copy.jpg, BlackandWhiteSticker.jpg, DarkFoil.jpg, myspace profile.jpg, NewPoliticalAgendaCover.jpg, PhilosophiesCover.jpg, picture001.jpg, picture002.jpg, picture006.jpg, picture007 - Copy.jpg

    As far as I can tell that's exactly right. That's all twelve images in the album preceded by username, and album name. I'll check firebug tonight and post what that's saying..
     
    Jeremy Benson, Jul 10, 2014 IP
  7. PoPSiCLe

    PoPSiCLe Well-Known Member

    Messages:
    1,750
    Likes Received:
    175
    Best Answers:
    64
    Trophy Points:
    160
    #7
    Well, since you get the alt-text, but not the image, the image-src/url is probably not correct. I'd check to see what gets output in the img-element.
     
    PoPSiCLe, Jul 10, 2014 IP
  8. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #8
    When I got home I looked at the links. There is something strange going on. If Firebug I get... Shoot I was gonna show you the link but my recent copy of the site is on a flash drive at home. I'll pseudo what's happening if it helps.

    I'm supposed to get a link like this...

    users/Famous4/images/albums/albumname/image1.jpg

    but I'm getting something like this...

    users/EBF%%EBFFamous4/images/albums/albumname/image1.jpg

    It's putting some kind of weird string before the username. Not sure if it's a memory address, or something, don't have a clue..
     
    Jeremy Benson, Jul 11, 2014 IP
  9. PoPSiCLe

    PoPSiCLe Well-Known Member

    Messages:
    1,750
    Likes Received:
    175
    Best Answers:
    64
    Trophy Points:
    160
    #9
    I think it might have to do with your quotes in the strings.
    Instead of escaping all the double quotes, you're not escaping some...
    Try redoing the string concoctions like this:
    Code (Text):
    1.  
    2. window.document.getElementById('albumimage5').innerHTML = '<img height="120" width="90" alt="' + output[6] +'" src="users'+ output[0] +'/images/albums/' + output[1] + '/' + output[6].substring(0, output[6].indexOf('.')) + '_tmb' + output[6].substring(output[6].indexOf('.'), output[6].length) + '" />';
    3.  
    Change the numbers as needed, of course
     
    PoPSiCLe, Jul 11, 2014 IP
  10. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #10
    Awesome. I'll try that when I get home :) Thanks again.
     
    Jeremy Benson, Jul 11, 2014 IP
  11. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #11
    lol, I signed into digital point and saw that sign with the car driving off the road, and was like that's where my projects headed, lol.

    This is weird. I wrote all the strings out as you have them in single quotes. I still get alt text, but now Firebug doesn't throw errors. I took one of the strings and took out all the variables out and wrote in what would be interpolated and the path was a perfect match to what it is when I just put an image tag in the html code and the image shows. I put the two string paths in notepad and scratched my head for awhile trying to find the difference. After that I took the strings and wrote a mini program to test a tripple equal comparison. They didn't match, but yet they were identical. I saved the notepad file and got a unicode character warning. I figured the code had characters in it, so I took all the code that would make paths to the images and put them in notepad, but they saved without any unicode warning. I don't know if the unicode characters got in there while I was backspacing the variables to write in what would be interpolated, or if it was already in the code...
     
    Jeremy Benson, Jul 14, 2014 IP
  12. PoPSiCLe

    PoPSiCLe Well-Known Member

    Messages:
    1,750
    Likes Received:
    175
    Best Answers:
    64
    Trophy Points:
    160
    #12
    That is weird, but it might have something to do with how the files are saved (which character encoding) and how the data is being pulled from a database (and which character encoding you're using in your db).
    I say always go for UTF-8 or similar, never trust anything Win-specific. And make sure that all connections to the DB are made with the same character encoding as the output files.
     
    PoPSiCLe, Jul 14, 2014 IP
  13. deathshadow

    deathshadow Prominent Member

    Messages:
    6,382
    Likes Received:
    947
    Best Answers:
    155
    Trophy Points:
    395
    #13
    1) Why are you adding a trailing slash to the thumbnail name?

    2) I'd really suggest using 'lastIndexOf' instead of 'indexOf' to find the extension 'break'.

    3) You're in a programming language, use a loop instead of redundant code.

    4) It's usually faster executing if you only do the getElementById once at the start and store them in an array.

    5) You should REALLY be using the DOM instead of the sloppy innerHTML mess.

    6) generally one should only have to say "document", not "window.document"

    Guessing wildly, but:
    Code (Text):
    1. function change_photoalbum(IDSet) {
    2.  
    3.     var
    4.         id = IDSet,
    5.         idData = {
    6.             "IDSet" : id,
    7.             "from" : "dashboard"
    8.         },
    9.         output = [],
    10.         targets = [],
    11.         d = document;
    12.        
    13.     for (var t = 1; t < 14; t++) {
    14.         targets.push(d.getElementById('albumImage' + t));
    15.     }
    16.    
    17.     function flush(e) {
    18.         while (e.firstChild) e.removeChild(e.firstChild);
    19.     }
    20.    
    21.     function make(tagName, contents, attribs, parent) {
    22.         var e = d.createElement(tagName);
    23.         if (contents) e.appendChild(
    24.             typeof contents == 'object' ? contents : d.createTextNode(contents)
    25.         );
    26.         if (attribs) for (var i in attribs) e[i] = attribs[i];
    27.         if (parent) parent.appendChild(e);
    28.         return e;
    29.     }
    30.        
    31.     $.ajax({
    32.         type : "POST",
    33.         url" : "../mechanics/scripts/php/getphotoalbum.php",
    34.         dataType : "html",
    35.         data : idData,
    36.         "success" : function(data) {
    37.             for (var t = 0; t < target.length; t++) e.flush(targets[t]);
    38.          
    39.             if (data != "") {
    40.                 output = data.split(',');
    41.                 d.getElementById('albumnameoutput').innerHTML = output[1];
    42.                 d.addalbumform.albumName.value = output[1];
    43.                 alert(data);
    44.                
    45.                 var
    46.                     path = 'users/' + output[0] + 'images/albums/' + output[1] + '/';
    47.                
    48.                 for (var t = 0; t < targets.length; t++) {
    49.                     var
    50.                         name = output[t + 2],
    51.                         extPos = name.lastIndexOf('.'),
    52.                     make('img', false, {
    53.                         height : '120',
    54.                         width : '120',
    55.                         alt : name,
    56.                         src : path + name.substring(0, extPos) +
    57.                             '_tmb' + name.substring(extPos)
    58.                     }, targets[t]);
    59.                 }
    60.             }
    61.         }
    62.     });
    63. }
    Heading to bed so I've not dug into your PHP too deep, but tomorrow I'll try to put together a quick demo of this to show what I mean.... though that dbconnect object looks too complex for it's own good and/or redundant to what mysqli or PDO can already do. Also the 'stuff the entire query and it's associated data onto a single line' bit can't be making your life any easier either... much less that memory wasting '$returnstring' nonsense.
     
    deathshadow, Jul 15, 2014 IP
  14. Jeremy Benson

    Jeremy Benson Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #14
    Ah the sql object just runs queries as it normally would. There's an array for getting one value with fetch, and a multidimensional array for getting more values. I use select, select_all,get, get_all functions for each type. I like it cuz it cut down the code in the front end files...

    As for that code it looks good, but I can only half understand it... I'll try to study it a bit more. I'm confused about the part here..

    Code (Text):
    1.  
    2. function make(tagName, contents, attribs, parent) {
    3.   var e = d.createElement(tagName);
    4.   if (contents) e.appendChild(
    5.   typeof contents == 'object' ? contents : d.createTextNode(contents)
    6.   );
    7.   if (attribs) for (var i in attribs) e[i] = attribs[i];
    8.   if (parent) parent.appendChild(e);
    9.   return e;
    10.   }
    11.  
    Does it matter that I already have div objects in my html where I plan on placing the images? It just looks like here it's creating elements?
     
    Jeremy Benson, Jul 15, 2014 IP
  15. deathshadow

    deathshadow Prominent Member

    Messages:
    6,382
    Likes Received:
    947
    Best Answers:
    155
    Trophy Points:
    395
    #15
    Sounds like you'd be better off just using PDO the way PDO works -- though methods like "get all" or even pdo's ::fetchAll introduce so much memory overhead, you're usually best off just saying "no" to it. Dumping the entire result set into an array is just a waste of memory AND processing time.

    Besides, is it really such a big deal to type:
    Code (Text):
    1. $statement = $db->prepare('
    2.     SELECT
    3.         userName, albumName,
    4.         photo1name, photo2name, photo3name, photo4name, photo5name, photo6name,
    5.         photo7name, photo8name, photo9name, photo10name, photo11name, photo12name,
    6.         albumViews
    7.     FROM photoalbums
    8.     WHERE ID = ?
    9. ');
    10. $db->execute([$albumID]);
    Instead of what you were doing? I mean, looking at what you were doing, why not:
    Code (Text):
    1. <?php
    2.  
    3. /* assuming $db is a connected PDO object */
    4.  
    5. $albumStmt = $db->prepare('
    6.     SELECT
    7.         userName, albumName,
    8.         photo1name, photo2name, photo3name, photo4name, photo5name, photo6name,
    9.         photo7name, photo8name, photo9name, photo10name, photo11name, photo12name,
    10.         albumViews
    11.     FROM photoalbums
    12.     WHERE ID = ?
    13. ');
    14. $albumStmt->execute([$_POST['IDSet']]);
    15.  
    16. if ($albumInfo = $albumStmt->fetch()) {
    17.  
    18.     if ($_POST['from'] != "dashboard") {
    19.         $updateStmt = $db->prepare('
    20.             UPDATE photoalbums
    21.             SET albumViews = ?
    22.             WHERE ID = ?
    23.         ');
    24.         $updateStmt->execute([ ++$albumInfo['albumViews'], $_POST['IDSet']);
    25.     }
    26.    
    27.     // Send information back to profile.
    28.     echo implode(',', $albumInfo);
    29.    
    30. } else {
    31.     // you should really have a 0 matching rows handler here!
    32. }
    33.  
    34. ?>
    Not really seeing how adding more overhead is saving you anything there...

    Though I do have a big question... are you really sure you want to hard-code the number of possible images? I mean, we have RELATIONAL databases for a reason. I mean why not have one table for users, one table for albums, and one table for photos?

    users:
    id (unique, auto-increment)
    name
    other info

    albums:
    id (unique, auto-increment)
    user_id (indexed)
    name
    views

    photos:
    id (unique, auto-increment)
    album_id (indexed)
    name

    Ends up more queries, but of smaller tables... and means an album could have any number of images. Would also be easier to process client or server-side.

    Generally hard-coding fixed-numbers of items will bite you sooner or later.

    Well, lemme go through piece by piece and explain it.

    I create a 'd' elemement just to make it a bit less unwieldy with all the times we call document. The 'targets' array gets filled with your albumimage DIV. (though I think I miscounted/misaligned to your logic).

    The flush function does the same thing as innerHTML = ''; except that it doesn't force a reflow/reparse of the page. As a rule innerHTML should be avoided unless you REALLY need it. Manipulating the DOM is faster running, smoother showing and in general a superior way of doing things.

    The make function does indeed just make a new element and plug contents (either as a object or text) and attributes onto it. Pay attention to 'parent' -- if you pass that value, the 'appendChild' method plugs the newly created element into that one. Basically, this ALSO replaces the innerchild="<img>" you were using -- again manipulating the DOM instead.

    In the 'success' method we just go through and 'flush' the contents of all the elements we stored in the target array -- those would be your DIV you want to plug the images into.

    I store the path beforehand as it's used more than once. Any operations you use more than once should be pre-done so you aren't repeating doing the same thing over and oer again -- likewise if you can do something outside the loop should be done so as to speed up execution. Hence why I do the same for the name and position of the period.

    Though - oops, typo. Should be a semi-colon not a comma after extPos. What I get for typing it into the post box and not testing :D

    We then just call the make function to create a whole new IMG tag, and plug it into the appropriate DIV from the targets array.

    Though again, I was guessing as I've got no clue what your markup looks like. If I were implementing something like this, I'd probably NOT have the multiple DIV, and instead have a single parent container into which I'd plug ALL the images, again using the DOM.

    I'd probably also swing an axe at what I can only assume is jQuery, since it's taking too much control out of your hands on this; and 99% of the time is pointless slow code bloat that has no business on a website in the first place.
     
    deathshadow, Jul 15, 2014 IP