Change image size depending on page
Yes, there is. You are looking for the thumbnail image size, I would say. So, for each post, don’t just do the_post_thumbnail();, instead do the_post_thumbnail(‘thumbnail’);.
Yes, there is. You are looking for the thumbnail image size, I would say. So, for each post, don’t just do the_post_thumbnail();, instead do the_post_thumbnail(‘thumbnail’);.
Yes, NGG can be used exactly like you described it. under Other Settings you find the Lightbox Effects where you can select Fancybox, and click Show Advanced Options. That’s where you can find/set class=”fancybox” rel=”gallery” and you’re good to go. To show single images you can use the shortcode [singlepic id=47 …], for instance.
WordPress resizes the image when you upload it. By default it provides 4 sizes of your image (providing your image is bigger than the ‘large’ size). the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x 150px max) the_post_thumbnail(‘medium’); // Medium resolution (default 300px x 300px max) the_post_thumbnail(‘large’); // Large resolution (default 640px x 640px max) the_post_thumbnail(‘full’); // Original … Read more
If you want to use add_image_size, your images must be uploaded as WordPress attachments, and not only be present inside a specific folder. So first of all register your custom size: add_action( ‘after_setup_theme’, ‘gmrb_background_image_size’ ); function gmrb_background_image_size() { // using WP 3.9 crop position // see https://codex.wordpress.org/Function_Reference/add_image_size#Crop_Mode add_image_size( ‘gmrb_background’, 1500, 1500, array( ‘center’, ‘center’) ); … Read more
Ankit you can re-size images by using this script via terminal: <?php ini_set(‘max_execution_time’, 0); set_time_limit(0); require_once(‘./wp-load.php’); require_once( ‘./wp-admin/includes/admin.php’ ); for($i=0;$i<=500;$i++){ $attachments =& get_children(array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘numberposts’ => 50, ‘paged’ => $i, ‘post_status’ => null, ‘post_parent’ => null ), ARRAY_A); foreach ( $attachments as $attachment ) { $image = get_post($attachment[‘ID’]); $original_size_path = … Read more
From my understanding I can’t get the image IDs directly from wordpress. I have to first get their URLs and then extract their IDs. If there is a more efficient way to do this please let me know. I’m not sure I follow you there, but did you try this: $ids = get_posts( array( ‘post_type’ … Read more
Try this : <ul> <?php $args = array( ‘category_name’ => ‘महाराष्ट्र’, ‘post__in’ => get_option( ‘sticky_posts’ ), ‘showposts’ => ‘6’, ); $the_query = new WP_Query( $args ); $count = 1; while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <li> <?php if ( 1 == $count ): ?> <div class=”thumbnail_class”><a title=”<?php the_title(); ?>” href=”https://wordpress.stackexchange.com/questions/150086/<?php the_permalink() ?>” … Read more
With wp_get_attachment_image_src you get a array with values corresponding to the (0) url, (1) width, (2) height, and (3) scale of an image attachment (from the wordpress doc). you code can be: if($imageid){ $image_attributes = wp_get_attachment_image_src( $imageid, ‘custom-size-01’, false); echo “<img src=\””; echo $image_attributes[0]; echo “\” width=\”100%\” >”; }
Did you read doc for set_post_thumbnail()? You need either post object or post ID for the set_post_thumbnail() function. The function wp_insert_post() will return post id on success. You can use that post id to set the thumbnail image. Here is the modification for your last couple of lines $post_id = wp_insert_post( $my_post ); if(!$post_id){ // … Read more
First, don’t let Google Insights drive you to chase an ROI that might not be there. Maybe for 1M of image data improvement, it is worth looking into – but after awhile that tool will have you minifying 1K css files to save 100 bytes. Second, regarding images – don’t just blindly reduce (‘compress’…really a … Read more