/** * Apply the Vimeo short code * * @param string &$content * @param Fishpig_Wordpress_Model_Post_Abstract $object * @return void */ protected function _apply(&$content, Fishpig_Wordpress_Model_Post_Abstract $object) { if (($shortcodes = $this->_getShortcodes($content)) !== false) { foreach ($shortcodes as $it => $shortcode) { $args = $shortcode->getParams(); if (!$args->getColumns()) { $args->setColumns(3); } if (!$args->getSize()) { $args->setSize('thumbnail'); } if (!$args->getLink()) { $args->setLink('attachment'); } if ($args->getPostId()) { if ($args->getPostId() !== $params['object']->getId()) { $post = Mage::getModel('catalog/post')->load($args->getPostId()); } } if (($ids = trim($args->getIds(), ',')) !== '') { $images = new Varien_Data_Collection(); foreach (explode(',', $ids) as $imageId) { $image = Mage::getModel('wordpress/image')->load($imageId); if ($image->getId()) { $images->addItem($image); } } } else { $images = $object->getImages(); } $html = $this->_createBlock('wordpress/template')->setImageCollection($images)->setColumns($args->getColumns())->setPost($object)->setSize($args->getSize())->setLink($args->getLink())->setGalleryIt($it + 1)->setTemplate('wordpress/shortcode/gallery.phtml')->setAfterGalleryScript(Mage::helper('wp_addon_lightboxgallery')->getAfterGalleryScript($it + 1))->toHtml(); $content = str_replace($shortcode->getHtml(), $html, $content); } } }
/** * Retrieve the featured image for the post * * @param Fishpig_Wordpress_Model_Post_Abstract $post * @return Fishpig_Wordpress_Model_Image $image */ public function getFeaturedImage(Fishpig_Wordpress_Model_Post_Abstract $post) { if ($images = $post->getImages()) { $select = $this->_getReadAdapter()->select()->from($this->getTable('wordpress/post_meta'), 'meta_value')->where('post_id=?', $post->getId())->where('meta_key=?', '_thumbnail_id')->limit(1); if (($imageId = $this->_getReadAdapter()->fetchOne($select)) !== false) { if (preg_match('/([a-z-]{1,})([0-9]{1,})/', $imageId, $matches)) { if (($prefix = trim($matches[1], '- ')) !== '') { $eventData = array('object' => $post, 'image_id' => $matches[2], 'original_image_id' => $imageId, 'result' => new Varien_Object()); Mage::dispatchEvent('wordpress_post_get_featured_image_' . $prefix, $eventData); if ($eventData['result']->getFeaturedImage()) { return $eventData['result']->getFeaturedImage(); } } } else { return Mage::getModel('wordpress/image')->load($imageId); } } } return false; }
/** * Retrieve the featured image for the post * * @param Fishpig_Wordpress_Model_Post_Abstract $post * @return Fishpig_Wordpress_Model_Image $image */ public function getFeaturedImage(Fishpig_Wordpress_Model_Post_Abstract $post) { if ($images = $post->getImages()) { $select = $this->_getReadAdapter()->select()->from(Mage::helper('wordpress/db')->getTableName('postmeta'), 'meta_value')->where('post_id=?', $post->getId())->where('meta_key=?', '_thumbnail_id')->limit(1); if ($featuredImageId = $this->_getReadAdapter()->fetchOne($select)) { return Mage::getModel('wordpress/image')->load($featuredImageId); } } }