From e4bf0b036a65f3cfe9796d29e0e268e529f5215f Mon Sep 17 00:00:00 2001 From: Alexis Monnet Date: Tue, 6 Sep 2016 17:37:23 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Ajout=20d'un=20nouvel=20attribut=20pour=20a?= =?UTF-8?q?voir=20le=20lien=20absolu=20de=20"l'image=20=C3=A0=20la=20une"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generic/WordpressBundle/Repository/Post.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sources/sf2/Generic/WordpressBundle/Repository/Post.php b/sources/sf2/Generic/WordpressBundle/Repository/Post.php index badc8af..7a697f5 100644 --- a/sources/sf2/Generic/WordpressBundle/Repository/Post.php +++ b/sources/sf2/Generic/WordpressBundle/Repository/Post.php @@ -8,6 +8,7 @@ class Post private $metas = array(); private $type = 'post'; private $tags; + private $linkImg = ''; public function getWPPost() { @@ -37,6 +38,10 @@ public function setMeta($key, $value) return $this; } + public function getLinkImg(){ + return $this->linkImg; + } + public function __construct($post = null) { $this->wp_post = $post; @@ -47,7 +52,14 @@ public function __construct($post = null) $this->type = $this->wp_post->post_type; } if ($this->wp_post->ID!=null) { - $this->metas = get_metadata('post', $this->wp_post->ID); + $this->metas = get_metadata('post', $this->wp_post->ID); + if(!empty($this->metas["_thumbnail_id"])){ + $idAttachment = $this->getMeta("_thumbnail_id"); + if(!empty($idAttachment)){ + $link = wp_get_attachment_image_src($idAttachment[0]); + $this->linkImg = $link[0]; + } + } } } From f0cd94b1ea376afb4e37621eac1d4a5852677d19 Mon Sep 17 00:00:00 2001 From: Alexis Monnet Date: Tue, 6 Sep 2016 17:42:22 +0200 Subject: [PATCH 2/2] Correction condition --- .../sf2/Generic/WordpressBundle/Repository/Post.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sources/sf2/Generic/WordpressBundle/Repository/Post.php b/sources/sf2/Generic/WordpressBundle/Repository/Post.php index 7a697f5..158ee61 100644 --- a/sources/sf2/Generic/WordpressBundle/Repository/Post.php +++ b/sources/sf2/Generic/WordpressBundle/Repository/Post.php @@ -53,12 +53,10 @@ public function __construct($post = null) } if ($this->wp_post->ID!=null) { $this->metas = get_metadata('post', $this->wp_post->ID); - if(!empty($this->metas["_thumbnail_id"])){ - $idAttachment = $this->getMeta("_thumbnail_id"); - if(!empty($idAttachment)){ - $link = wp_get_attachment_image_src($idAttachment[0]); - $this->linkImg = $link[0]; - } + $idAttachment = $this->getMeta("_thumbnail_id"); + if(!empty($idAttachment)){ + $link = wp_get_attachment_image_src($idAttachment[0]); + $this->linkImg = $link[0]; } } }