Thumbnail issue on playlist
-
Hi I am hopping you can help me. I am using Nelio Content, “External Featured Images” My site is a music website that allows people to add playlist. A Playlist will pull a featured image as a thumbnail. Album covers also use Feartured images. When using Nelio, everything is working except the playlist. The image isn’t showing. Is it possible to let me know what the problem is? If I using the ordinary “Featured Image” it works.
Thanks
-
Hi!
It looks like an issue tightly related to your theme (or the plugin you’re using for albums/playlists). Can you further elaborate on how the setup works?
Thanks!
DavidHi David, so right now, Its a custom post, just like a regular post except that it has a place to put some music information (.mp3 etc.) for the images, it is using the Featured Image to display thumbnails. When I use The Nelio Content plugin, The External featured image works as it should. The only place it doesn’t work is when I tried to add a music tracks to a playlist. Apparently the playlist is not showing the url.
I believe that this is how the playlist is trying to find the image.
<a href="#"> <img width="40" src="." alt="." /> </a>
Also I believe that this is the code that in used for the featured images.
`
<div class=”item-media <?php echo esc_attr( $media_class ); ?>”>
<?php $image = wp_get_attachment_image_url( get_post_thumbnail_id(), $media_size ); ?><a>” class=”item-media-content” style=”background-image: url(<?php echo esc_url( $image ); ?>);”></a>
</div>`External featured image works as it should. The only place it doesn’t work is when I tried to add a music tracks to a playlist. Apparently the playlist is not showing the url.
I believe that this is how the playlist is trying to find the image.
<a href="#"> <img width="40" src="." alt="." /> </a>
Also I believe that this is the code that in used for the featured images.
<?php $image = wp_get_attachment_image_url( get_post_thumbnail_id(), $media_size ); ?> <a href="<?php the_permalink(); ?>" class="item-media-content" style="background-image: url(<?php echo esc_url( $image ); ?>);"></a>
- This reply was modified 7 years, 8 months ago by linwilvic.
I also found this. Not sure if it matters but I figured I post it.
// get post thumbnail function ff_get_post_thumbnail($post_id, $size = 'thumbnail', $src = true){ $img = ''; if(!$src){ return the_post_thumbnail(); } $thumbnail_id = get_post_thumbnail_id( $post_id ); if( !empty( $thumbnail_id ) ){ $img = wp_get_attachment_image_url( $thumbnail_id, $size ); }else{ $img = get_post_meta($post_id, 'cover', true); } return $img; }
Hello David,
Sorry for all the post but this is what I finally got from the developer of the themes.When adding track to playlist, the playlist will use the track thumbnail id. the code is in includes/class-ff-music.php line 83-84
$thumbnail = get_post_thumbnail_id( $post_id ); set_post_thumbnail($id, $thumbnail);
Do you think I need to add something in that code for Nelio featured Image to work?
Hi again!
Thanks for looking into this ?? I suppose the theme uses two different approaches for displaying features images: one for songs, another for playlists.
I tried to think of a solution, but it’s quite complicated to describe here. Can you please send me a copy of your theme (customers at nelio software dot com), so that I can try to implement it locally? Once I have a running solution, I can send you the fix.
Hi David,
Thanks for deciding to look into this. I just send you an email with a google drive link to the file.Thanks
Thanks! I’ll look into it and get back to you as soon as I know how to fix the compatibility issue.
Ok
Hi!
I installed the theme and I’ve been playing around a little bit. Indeed, it looks like there are some compatibility glitches between our EFI feature and this theme.
Can you please describe exactly what’s happening? Do you have a featured image in “Music”? Do you have it in “Track”? When does the issue arise? What’s happening and what should happen instead? It’s a pretty complicated theme (and plugin too: Pliklist), and I don’t know where to start.
Hi David, so right now everything is working except when I tried to add playlist. I crated an account for you and send the credentials to your email if you would like to take a look. https://app2.wlojii.com/wp-login.php
So basically, when you click on a track to add to playlist, https://drive.google.com/open?id=0BwjoDy2PwkrxdUllbXJTRmYxQW8
A thumbnail is supposed to show up like this:
https://drive.google.com/open?id=0BwjoDy2PwkrxdHpZMFFwY3ZFcjAWith the normal Featured Image, It works. But with Nelio, it doesn’t. Everthing else work. The main custom post type is call “Tracks” fYI.
When I reached out to the developer of the theme, This is what he said,
“When adding track to playlist, the playlist will use the track thumbnail id. the code is in includes/class-ff-music.php line 83-84”
$thumbnail = get_post_thumbnail_id( $post_id ); set_post_thumbnail($id, $thumbnail);
I also believe that this template is being used for the featured images.
/templates/loop/list-music.php
Hi!
Thanks again for all your help. I think I have a workaround ready, but I’m afraid it requires some “theme tweaking”.
First of all, let’s create a helper function that we’ll use a couple of times. You can add it in the end of
functions.php
:if ( ! function_exists( 'nc_get_efi_url' ) ) { function nc_get_efi_url( $post_id ) { if ( ! class_exists( 'Nelio_Content_External_Featured_Image_Helper' ) ) { return false; }//end if $aux = Nelio_Content_External_Featured_Image_Helper::instance(); return $aux->get_nelio_featured_image( $post_id ); }//end nc_get_efi_url() }//end if
Now we need to update the theme itself. In particular, we need to modify functions
add_playlist
andget_playlist
inincludes/class-ff-music.php
.In
add_playlist
you need to change what you told me (lines 83-84):$thumbnail = get_post_thumbnail_id( $post_id ); set_post_thumbnail($id, $thumbnail);
with the following piece of code:
$efi = nc_get_efi_url( $post_id ); if ( $efi ) { update_post_meta( $id, '_nelioefi_url', $efi ); } else { $thumbnail = get_post_thumbnail_id( $post_id ); set_post_thumbnail($id, $thumbnail); }//end if
Now, once you set the thumbnail properly, we need to return the appropriate image. So, right before the
return
statement, add this:if ( $efi ) { $obj['thumb'] = $efi; }//end if return $obj;
Then, let’s fix
get_playlist
. In this particular, locate theforeach
block and add the following snippet at the end (right after a new element has been added to theobj
array):$efi = nc_get_efi_url( $post->ID ); if ( $efi ) { $obj[ count( $obj ) - 1 ]['thumb'] = $efi; }//end if
And that’s it! These changes should fix your issue. Let me know if they worked!
Remember that any theme update will get rid of them, so make sure you save them, so that you can re-apply them when needed.
All the best,
David- This reply was modified 7 years, 8 months ago by David Aguilera.
Hi David,
I just want to take this time so thanks you for helping me fix this problem. You are awesome. It is finally working!!! I am using a child-theme and I trid copying that file over but that didn’t work. But no worries, I have that code stored in a safe place for whenever the theme gets updated.Once again, Thanks so much for you help.
Lincoln
Hey David,
is there a donation link for Nelio Content? I am considering using “Nelio Content Personal” in the future, but for now, I would like to donate.Thanks
Lincoln
- The topic ‘Thumbnail issue on playlist’ is closed to new replies.