@@ -161,7 +161,7 @@ function feedzy_el_display_external_post_image( $html, $settings, $image_size_ke
161
161
* @param int|false $thumbnail_id Post thumbnail ID or false if the post does not exist.
162
162
* @return bool
163
163
*/
164
- function enable_external_url_support ( $ has_thumbnail , $ post , $ thumbnail_id ) {
164
+ function feedzy_enable_external_url_support ( $ has_thumbnail , $ post , $ thumbnail_id ) {
165
165
$ post_id = get_the_ID ();
166
166
if ( $ post && is_object ( $ post ) ) {
167
167
$ post_id = $ post ->ID ;
@@ -175,7 +175,28 @@ function enable_external_url_support( $has_thumbnail, $post, $thumbnail_id ) {
175
175
}
176
176
return $ has_thumbnail ;
177
177
}
178
- add_filter ( 'has_post_thumbnail ' , 'enable_external_url_support ' , 10 , 3 );
178
+ add_filter ( 'has_post_thumbnail ' , 'feedzy_enable_external_url_support ' , 10 , 3 );
179
+
180
+ /**
181
+ * Filters the attachment image source.
182
+ *
183
+ * @param array|false $image Either array with src, width & height, icon src, or false.
184
+ * @param int $attachment_id Image attachment ID.
185
+ * @param string|int[] $size Size of image. Image size or array of width and height values (in that order).
186
+ * @param bool $icon Whether the image should be treated as an icon.
187
+ * @return array|false
188
+ */
189
+ function feedzy_get_attachment_image_src ( $ image , $ attachment_id , $ size , $ icon ) {
190
+ if ( 0 === $ attachment_id ) {
191
+ $ external_url = get_post_meta ( get_the_ID (), 'feedzy_item_external_url ' , true );
192
+ if ( $ external_url ) {
193
+ $ image = array ( $ external_url , 0 , 0 , false );
194
+ }
195
+ }
196
+ return $ image ;
197
+ }
198
+
199
+ add_filter ( 'wp_get_attachment_image_src ' , 'feedzy_get_attachment_image_src ' , 10 , 4 );
179
200
180
201
/**
181
202
* Boostrap the plugin view.
0 commit comments