/    Sign up×
Community /Pin to ProfileBookmark

Is there a bug in this code impacting thumbnail?

Hello,
The formatting of the thumbnail on the left is off. It should look the thumbnail on the right. See here.
https://screencast.com/t/M2it2aIG67

Can you tell if there is something in the code below that is causing that thumbnail to not display correctly? Thanks a lot

<div class=”elementor-post__thumbnail elementor-fit-height”><img width=”300″ height=”200″ src=”<?php echo get_the_post_thumbnail_url(); ?>” class=”attachment-medium size-medium” alt=”” srcset=”<?php echo get_the_post_thumbnail_url(); ?> 300w, <?php echo get_the_post_thumbnail_url(); ?> 1024w, <?php echo get_the_post_thumbnail_url(); ?> 768w, <?php echo get_the_post_thumbnail_url(); ?> 1536w, <?php echo get_the_post_thumbnail_url(); ?>1920w” sizes=”(max-width: 300px) 100vw, 300px”></div>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJan 23.2020 — Looks like two images to me. You complaining about the corners? Check your web page source to see if the html looks like it should. Your code here is too complex to interpret easily. Try writing it differently perhaps. Maybe put each statement into its own echo and on its own line?
Copy linkTweet thisAlerts:
@ginerjmJan 24.2020 — I had some time to kill and here is how I read your jumble of code:
<i>
</i>echo "&lt;div class='elementor-post__thumbnail elementor-fit-height'&gt;";
echo "&lt;img width='300' height='200' src='" .
get_the_post_thumbnail_url() .
"' class='attachment-medium size-medium' alt='' srcset='" .
get_the_post_thumbnail_url() . " 300w, " .
get_the_post_thumbnail_url() . " 1024w, " .
get_the_post_thumbnail_url() . " 768w, " .
get_the_post_thumbnail_url() . " 1536w, " .
get_the_post_thumbnail_url() . " 1920w' sizes='(max-width: 300px) 100vw, 300px'&gt;";
echo "&lt;/div&gt;";


Looks like you are outputting one img tag into a single div. I am not familiar with the srcset clause you are using but I don't see a second image being displayed by this code so I am lost. But at least I can read it now. Not sure why you have all those calls to the 'get' function when you could just call it once, save the result and place that result into your code and not have to add all the concatenation (instead of your php mode-switches) to this long echo statement.

Of course - we haven't heard back form you OP, so maybe this was totally unnecessary.
Copy linkTweet thisAlerts:
@NogDogJan 24.2020 — In the original code snippet, there's no space before "1920w", so it would be concatenated onto the end of the preceding URL, in case that might be the problem?
×

Success!

Help @jojoma spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...