Переглянути джерело

Insert images using a loop.

Frederic G. MARAND 9 роки тому
батько
коміт
6004f7e8ba

+ 5 - 0
image_share.css

@@ -1 +1,6 @@
 /* CSS declarations go here */
+.thumbnail {
+    min-height:500px;
+    max-height:500px;
+
+}

+ 1 - 1
image_share.html

@@ -12,7 +12,7 @@
 <template name="images">
   <div class="row">
     {{#each images}}
-      <div class="col-xs-12 col-md-4">
+      <div class="col-xs-12 col-md-3">
         <div class="thumbnail">
 
           <img class="js-image" src="{{img_src}}" alt="{{img_alt}}" />

+ 1 - 1
image_share.js

@@ -1,5 +1,5 @@
+// this is image_share.js
 Images = new Mongo.Collection("images");
-Meteor._debug(Images.find().count());
 
 if (Meteor.isClient) {
   let imgData = [

BIN
public/bass.jpg


BIN
public/beard.jpg


BIN
public/img_1.jpg


BIN
public/img_10.jpg


BIN
public/img_11.jpg


BIN
public/img_12.jpg


BIN
public/img_13.jpg


BIN
public/img_14.jpg


BIN
public/img_15.jpg


BIN
public/img_16.jpg


BIN
public/img_17.jpg


BIN
public/img_18.jpg


BIN
public/img_19.jpg


BIN
public/img_2.jpg


BIN
public/img_20.jpg


BIN
public/img_21.jpg


BIN
public/img_22.jpg


BIN
public/img_3.jpg


BIN
public/img_4.jpg


BIN
public/img_5.jpg


BIN
public/img_6.jpg


BIN
public/img_7.jpg


BIN
public/img_8.jpg


BIN
public/img_9.jpg


BIN
public/laptops.jpg


+ 9 - 13
startup.js

@@ -1,18 +1,14 @@
 if (Meteor.isServer) {
   Meteor.startup(function () {
     if (Images.find().count() === 0) {
-      Images.insert({
-        "img_src": "laptops.jpg",
-        "img_alt": "some laptops on a table"
-      });
-      Images.insert({
-        "img_src": "bass.jpg",
-        "img_alt": "a bass player"
-      });
-      Images.insert({
-        "img_src": "beard.jpg",
-        "img_alt": "some musicians with beards"
-      });
-    }
+      for (let i = 1; i < 23; i++) {
+        Images.insert({
+          "img_src": "img_" + i + ".jpg",
+          "img_alt": "image number " + i
+        });
+      } // end of for loop
+      Meteor._debug(Images.find().count());
+    } // end of if have no images.
   });
+
 }