Wordpress - How to get a gif working as a Featured Image? Big Problem?!

DanielBlue

New member
Joined
Aug 15, 2017
Messages
27
Points
0
Since some time I am trying to get a gif working as a featured image on wordpress. I know it can be done but all modification I made till now did not work! They are working inside the post but not on the frontpage… any ideas?
 
Last edited:

Marc van Leeuwen

Premium Member
Joined
May 29, 2016
Messages
1,113
Points
63
You can add this code to functions.php in your theme folder

Code:
<?php $thumb_url = get_the_post_thumbnail_url();
	  $thumb_low = strtolower($thumb_url);
	  if (strpos($thumb_low, '.gif') === false) {
	  	$thumb_size = 'large';
	  } else {
	  	$thumb_size = 'full';
	  } ?>
Normally, Wordpress will process your featured images via this function the_post_thumbnail() and it will resize your image to 150x150 thus your gif image will not work. Now when you added that function then it will always display your image size as uploaded.

Hope that helped.
 

DanielBlue

New member
Joined
Aug 15, 2017
Messages
27
Points
0
Thank you but when adding the code the page is not working anymore at all. :(
 
Last edited:
Older threads
Replies
5
Views
5,732
Replies
2
Views
1,739
Replies
1
Views
2,719
Newer threads
Replies
30
Views
6,520
Replies
8
Views
5,039
Replies
0
Views
1,200
Latest threads
Replies
1
Views
13
Replies
2
Views
129
Replies
1
Views
190
Replies
6
Views
439
Replies
11
Views
548
Recommended threads
Replies
3
Views
3,026
Replies
6
Views
3,473
Replies
14
Views
6,309
Replies
11
Views
6,282

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top