adding featured flag to the getGallery method from the images data class
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 26 Oct 2017 13:18:39 +0000 (09:18 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 26 Oct 2017 13:18:39 +0000 (09:18 -0400)
adding filter in fronthooks to get member images or featured image if requested

classes/data/dataImages.php
setup/frontHooks.php

index a6aa642..8b03f6d 100644 (file)
@@ -223,7 +223,7 @@ class GlmDataImages extends GlmDataAbstract
      * @return object Class object
      *
      */
-    public function getGallery($refType, $refID )
+    public function getGallery($refType, $refID, $featured = false )
     {
 
         // Check for a valid reference type
@@ -239,11 +239,13 @@ class GlmDataImages extends GlmDataAbstract
             return false;
         }
 
-
         // Get all images matching $refType and $refID ordered by "position" number
         $where = "T.ref_type = $refType AND T.ref_dest = $refID";
+        if($featured){
+            $where .= ' AND featured = true';
+        }
         $imageGallery = $this->getList($where, 'T.position');
-
+        
         // Check if we found anything
         if (!is_array($imageGallery) || count($imageGallery) == 0) {
             return false;
index 60f7f96..8927196 100644 (file)
@@ -331,6 +331,12 @@ if (!function_exists('addUrlProtocol')) {
 /*
  *
  */
+add_filter('member_images', function($memberID, $featured=false){
+    require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
+    $Images = new GlmDataImages($this->wpdb, $this->config);
+    $imageGallery = $Images->getGallery($this->config['ref_type_numb']['MemberInfo'], $memberID,$featured);
+    return $imageGallery;
+});
 add_filter('member_categories', function(){
     include_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataCategories.php';
     $categories = new GlmDataCategories( $this->wpdb, $this->config );