소스 검색

:recycle: fixing attrs for attachment endpoint | adjusting single template to use new gallery data

tags/0.9.0
J 5 년 전
부모
커밋
c888ab7bec
2개의 변경된 파일12개의 추가작업 그리고 4개의 파일을 삭제
  1. 1
    1
      plugins/cia-endpoints/includes/class.make-endpoint.php
  2. 11
    3
      vue-theme/src/pages/single.vue

+ 1
- 1
plugins/cia-endpoints/includes/class.make-endpoint.php 파일 보기

@@ -57,7 +57,7 @@ class Make_Endpoint_For extends WP_REST_Controller {
57 57
         $all_image_ids_in_gallery = array();
58 58
         $all_image_ids = array();
59 59
         foreach ($galleries as $gallery) {
60
-            array_push($all_image_ids_in_gallery, $gallery[ids]);
60
+            array_push($all_image_ids_in_gallery, $gallery[attrs][ids]);
61 61
         }
62 62
         foreach ($all_image_ids_in_gallery as $ids) {
63 63
             foreach ($ids as $id) {

+ 11
- 3
vue-theme/src/pages/single.vue 파일 보기

@@ -14,8 +14,9 @@
14 14
             //- ?: are objects are always gallery blocks
15 15
             .gallery.block(v-if="typeof block === 'object'" :class="`gallery-${i}`")
16 16
                 p gallery number: {{ i }}
17
-                ul.t-cntr 
18
-                    li(v-for="(imageID, j) in post.galleries[block.gallery].ids" :class="`gallery-${i}--image-${j+1}`" :key="`block-${i}-${j}`")
17
+                p ids: {{ post.galleries[block.gallery].innerHTML }}
18
+                ul.t-cntr(v-if="post.galleries[block.gallery]")
19
+                    li(v-for="(imageID, j) in getImageIdsForGallery(block.gallery)" :class="`gallery-${i}--image-${j+1}`" :key="`block-${i}-${j}`")
19 20
                         img(@click="openGallery(i - 1, imageID)" :src="post.attached[imageID]['thumbnail']")
20 21
                         //- TO DO Caption stuff and full screen Title/Description
21 22
                         p Caption goes here<br>
@@ -86,6 +87,9 @@ export default {
86 87
             }, {})
87 88
         },
88 89
 
90
+        idsForGallery() {
91
+            return this.post.galleries[this.activeGalleryIndex].attrs.ids
92
+        },
89 93
         /**
90 94
          * We need a convenient way to get all the images
91 95
          * broken down by gallery. We use the active gallery
@@ -98,7 +102,7 @@ export default {
98 102
             // {
99 103
             //     imageId: { 'thumbnail': url, 'large': url }
100 104
             // }
101
-            return this.post.galleries[this.activeGalleryIndex].ids.reduce((imageMap, id) => {
105
+            return this.idsForGallery.reduce((imageMap, id) => {
102 106
                 imageMap[id] = this.post.attached[id]
103 107
                 return imageMap
104 108
             }, {})
@@ -108,6 +112,10 @@ export default {
108 112
         }
109 113
     },
110 114
     methods: {
115
+        getImageIdsForGallery(galleryIndex) {
116
+            console.log(galleryIndex)
117
+            return galleryIndex >= 0 ? this.post.galleries[galleryIndex].attrs.ids : []
118
+        },
111 119
         /**
112 120
          * We set the active gallery to the index.
113 121
          * Everything kicks off when activeGallery

Loading…
취소
저장