Trouble with a blurred thumbnail at my website project
Greetings.
Ladies And Gentleman
I ask some question about this picture I've sent, what I want to ask about is how to make
this picture's blurred thumbnail turned into High-Definition.
enter image description here
already try to turn off lazy loading with this code but loading="lazy"
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
Website using Wordpress
this is the link https://cloudteamize.com/test-porto/
Increase the size of the thumbnail on the Wordpress settings "Settings > Media" I suggest you put it at least 650px.
You will always see it blurry because is a flexible container and often stretch larger than the actual image size (It varies on viewport size or screen resolution).
pd: You will need to regenerate the thumbnails after or reupload the image and use the latest version. When you change those settings old images don't create the new thumbnail versions automatically.
THE SOLUTION IS FOUNDED:
the problem is the image link that my plugin using called: Portofolio Carousel is adding 350x181.png at the end of the link, I think that make my image use the lower quality.
example:
the original file is -> mmd.png
but in that plugin -> mmd-350x181.png
i take the values of my src then remove the 350x150.png to only .png using my massy javascript like this:
$ = jQuery;
$(document).ready(function() {
const imgs=document.querySelectorAll('#portofolio img');
imgs.forEach(img => console.log(img.removeAttribute('srcset'), img.removeAttribute('loading'),img.src=img.src.replace("-350x181","")));
});
some how if I not doing my code inside console.log, the code didn't run. I think that is really weird, but some how when I try to put that in console.log, it just works so if you can give me suggestions or make this code clearer, that's will be great.
Related
I found a weird bug, in cropping image in wordpress
I used WP_Customize_Cropped_Image_Control to crop image. In there I set the width 750 & height 500
that works well but that was showing error while cropping some other image
*It made me crazy, after spending so many hour, I realized that (the error and not showing cropping frame) it occur with the images
which have the same aspect ratio as I provided in WP_Customize_Cropped_Image_Control (if the aspect ratio matched then error occur)
if I don't provide aspect the ratio and set flex width and height then it works well
*Other thing I noticed that I have a wide image that is 1920 X 742
which takes the whole width of Crop Image modal of Wordpress, so there is also causing error (not showing cropping frame and showing error)
If I resize my browser window then It show the cropping frame and can crop the image without any error
After some long research, I understood that it is a known bug of a jQuery library that is used by Wordpress and this library has not been updated for a long time. There is a workaround but it is a bit tricky. If you really need it, here is the solution for the curious ones:
The file is /wp-includes/js/imgareaselect/jquery.imgareaselect.js
Copy your own version (do not make a change in core WP files) and put it like somewhere in your template directory for example a js directory. Find this code snippet:
imgWidth = $img.innerWidth();
imgHeight = $img.innerHeight();
change it to this
imgWidth = Math.ceil($img.innerWidth());
imgHeight = Math.ceil($img.innerHeight());
Then you should dequeue and deregister the core file and enqueue your version. In case you do not know how to do it, I also put it here for the ones who need it.
Put the code snippet in your functions.php file.
// change custom scripts example
add_action( 'wp_print_scripts', 'cleanup_scripts', PHP_INT_MAX);
add_action( 'wp_print_footer_scripts', 'cleanup_scripts', PHP_INT_MAX);
function cleanup_scripts() {
wp_deregister_script('imgareaselect');
wp_dequeue_script('imgareaselect');
wp_enqueue_script('imgareaselect', get_template_directory_uri() . '/js/jquery.imgareaselect.min.js', array('jquery'), '1.0', true);
}
'imgareaselect' is the handle of the file that is used by Wordpress core.
I also put the source here in case you want to dig deeper.
https://github.com/google/web-stories-wp/issues/8398
Sorry for the length, my problem is very simple, but specific.
I'm building a wordpress site that automatically imports image galleries from a Tumblr account, then styles and displays them. The backend is finished, and all that I need now is have all images in posts be displayed as thumbnail sized links. They are not behaving well with the importer (I've tried 6), so I have to edit the HTML display (rather than the images as they are uploaded).
I have decided to do this by applying class="attachment-thumbnail size-thumbnail" on all images on the site (in HTML). I have tested this and they will open the proper gallery in a lightbox as necessary so long as they belong to those two classes.
I have a two part problem.
I do not know PHP past basic syntax, and while I can intuit most of what is happening I don't trust myself to edit Wordpress source code without understanding exactly what I am breaking.
From other answers I've learned that I should most likely edit the wp_insert_attachment() function in post.php under wp_includes/. I have found the function, but don't really know where to go from there, as it does not appear to be specific to image attachments. I don't want to throw any errors by assinging image classes to non-image attachments. How do I add those two classes (attachment-thumbnail and size-thumbnail) to all post images (and only images)?
There is a single exception to this rule. I want a large image on the homepage, and have it not be a link.
It seems like the way to handle this would be to allow page attachments to be handled normally, while attachments that are both images and attached to posts should trigger this:
if [attachment is an image AND is on a post, not a page]:
<img src="https://whatever">
becomes
<img src="https://whatever" class="attachment-thumbnail size-thumbnail">
tl; dnr: ^^ that's all I need to happen, in PHP, in the right file, in Wordpress ^^
Thanks!
So likely you will want to do it via php but instead you could do it with javascript ie jQuery:
<script>
$(function() {
$("body img").addClass("attachment-thumbnail size-thumbnail");
});
</script>
Put that on any page or site header and it will add the class to all images. You can modify the search filter to suit.
You might need to re-call your lightbox initialization code too, or put this before it gets called initially.
I've been breaking my head over this for a few days but I yet have to find a proper solution. I'm working on a Wordpress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back to the media files directly (e.g. xyz.jpg).
The site has a significant number of posts and images so it would be impossible to do this manually.
Does anyone know of a plugin or other solution that would simply replace - in bulk - all of the image links to link to the media file, instead of the attachment page?
Here is one answer that, although jQuery-based, did the trick, and is much quicker than and safer than a PHP-script to go through the whole DB. The drawback is that it will link to the resized image url instead of the full image url. There's probably a way to catch that with jQuery as well, but this was enough for my needs.
$("article.my-post-class a img").each( function(){
var src = $(this).attr("src");
$(this).parent("a").attr("href", src);
});
I am working on wordpress(3.5.2) project but getting one issue in case of image resizing. In wordpress when i upload any image its auto resizing to thumbnail,medium and larger but the name of image taking like image-300x300.jpg but i want, for thumbnail it should be imagename-thmbnail.jpg, for medium imagename-medium.jpg and for large imagename-large.jpg
I have made changes in Setting/Media - image re-size but it not coming consistence image name .
I do appreciate for advance help.
If I follow you correctly Neil,
You are wanting the image files created in the WordPress upload/sizing routine to be named as follows:
[imgname]-thmbnail.jpg,
[imgname]-medium.jpg,
[imgname]-large.jpg.
To the best of my knowledge this is not an option. If you can provide more detail on why you want to do this I may be able to help more.
You can declare custom image sizes in your functions.php file like so:
`add_image_size( 'thmbnail', 80, 80, true );`
and then use it in your theme:
`the_post_thumbnail('thmbnail');`.
Just be aware WordPress uses the following natively: thumb, thumbnail, medium, large, post-thumbnail.
The solution to my problem is probably quite simple, but I can't find it.
I want a link under the images saying "view full size" that links to the original, full-sized picture. I've only find the $imagecache_path variable that prints the path to the node.
You should be able to theme the imagecache function and add a link the original there.
See:
http://api.lullabot.com/theme_imagecache
And:
http://api.drupal.org/api/function/theme_image/6