Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget showing full URL rather than thumbnail #84

Open
stirtingale opened this issue Mar 13, 2017 · 1 comment
Open

Widget showing full URL rather than thumbnail #84

stirtingale opened this issue Mar 13, 2017 · 1 comment

Comments

@stirtingale
Copy link

stirtingale commented Mar 13, 2017

Hi --

The mashable Widget was having issues on our site and returning a background URL that was the full URL not the thumbnail URL.

I manually changed wp_get_attachment_url to wp_get_attachment_image_src

( includes/class-mashsb-shared-posts-widget.php -- line 154 to 163)


                $image_url = wp_get_attachment_url( get_post_thumbnail_id($postID) );
                
                if (!empty($image_url)){
                    $css = 'background-image: url('.wp_get_attachment_url( get_post_thumbnail_id($postID) ).');background-size: cover;background-repeat: no-repeat;background-position: 50% 50%;width:'.$image_size.'px;height:' . $image_size . 'px;';
                    $image = !empty($image_size) ? '<div class="mashsb-widget-img" style="' . $css . '"><a class="mashsb-widget-link" href="' . get_the_permalink() . '" style="display:block;width:'.$image_size.'px;height:' . $image_size.'px;">&nbsp</a></div>' : '';
  
                } else {
                    $css = 'display:block;width:'.$image_size.'px;height:' . $image_size.'px;';
                    $image = !empty($image_size) ? '<div class="mashsb-widget-img" style="' . $css . '"><a class="mashsb-widget-link" href="' . get_the_permalink() . '">&nbsp</a></div>' : '';
                }
                               

to

                $image_url = wp_get_attachment_image_src( get_post_thumbnail_id($postID,'thumbnail') );
                
                if (!empty($image_url)){
                    $css = 'background-image: url('.$image_url[0].');background-size: cover;background-repeat: no-repeat;background-position: 50% 50%;width:'.$image_size.'px;height:' . $image_size . 'px;';
                    $image = !empty($image_size) ? '<div class="mashsb-widget-img" style="' . $css . '"><a class="mashsb-widget-link" href="' . get_the_permalink() . '" style="display:block;width:'.$image_size.'px;height:' . $image_size.'px;">&nbsp</a></div>' : '';
  
                } else {
                    $css = 'display:block;width:'.$image_size.'px;height:' . $image_size.'px;';
                    $image = !empty($image_size) ? '<div class="mashsb-widget-img" style="' . $css . '"><a class="mashsb-widget-link" href="' . get_the_permalink() . '">&nbsp</a></div>' : '';
                }

This resolves the issue for us

It would be awesome if you could specify the image size returned. Our thumbnail is much larger than the image dimensions we are using and we have a smaller custom image type that would be ideal

@JiveDig
Copy link

JiveDig commented Oct 18, 2018

This is a major issue IMO. It's causing us to go another route for our widgets. Loading a full size image in a widget without even the ability to filter the image size is not okay. Otherwise the plugin seems to be solid and works well. Nice job :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants