Tag Info

New answers tagged

-1

This simply doesn't work. Wordpress resizes the images while uploading, so if you don't upload them again, nothing will happen.


1

You are not providing a correct attachement ID. Replace: $image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true); With: $image_alt = get_post_meta( $image->id, '_wp_attachment_image_alt', true); Note: I assume that $image->id is correct because you use it later in your code and you get the expected result. Unfortunatley ...


0

you need to have predefined image sizes, WP have 3 default sizes as 100x100 thumbnail, 300x300 medium and 800x800 large, and I have an aditional size called img-polaroid 700x320 defined on functions.ini. So the code to get images is: $image_id=get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'img-polaroid'); ...


0

jQuery( document ).ready(function() { jQuery("figure").addClass("wp-caption"); }); You could use jQuery to add a class.


0

Create a php script ( fpw-swap-thumbnails.php ) with the code below and put it in root of your site: <?php // load WordPress environment require( 'wp-load.php' ); $args = array( 'posts_per_page' => -1, 'post_status' => 'publish' ); // get all published posts $posts = get_posts( $args ); foreach ( $posts as $post ) { // get thumbnails ...


0

... leads me to believe wp_get_attachment_image_src( $thumb_id, array(100, 100) )[0] would return a 100x100 thumbnail... That isn't quite what happens. Most of the work is done by image_downsize() as you can see from near the top of the wp_get_attachment_image_src() : 692 // get a thumbnail or intermediate image if there is one 693 if ...


0

You can use a conditional function to check whether the page being accessed is using a page template and if so, display .... code. is_page_template( 'about.php' ) The above is the specific function and it could be used in an if statement, like so: if ( is_page_template( 'my_template.php' ) ) { // Display Code } You could also do an if/else and ...


0

You can use the remove_post_type_support for your requirement. In your case, you remove post thumbnail if specific page template is not selected. function remove_post_thumb(){ if (isset($_GET['post'])) { $post_id = $_GET['post']; } else if (isset($_POST['post_ID'])) { $post_id = $_POST['post_ID']; } else { return; } ...


0

Well, turns out now that I have access to the blog's admin control panel, that there's a really out of date plug-in being used to redirect to the main blog's mobile site. I can only make guesses at how it's breaking normal template tag behavior, but disabling it fixes the problem. So not quite as mysterious of a problem as it initially seemed to be.


0

The template tags shouldn't return different values depending on the mobile browser. It's strange. Here are some usual suspects to check: Do you have any cache plugin installed? If so, disable it for your tests. Any .htaccess rules defined only for mobile browsers? That might explain different behaviors. Do you still get the right results on your computer ...


0

Hello @Wisdmlabs Thank you for your help. I have found this to work very well incase anyone else is wondering how to do so. <?php $taxonomyName = "product_cat"; $prod_categories = get_terms($taxonomyName, array( 'orderby'=> 'name', 'order' => 'ASC', 'hide_empty' => 1 )); foreach( ...


0

Have did some customization. This will help you show parent and child category images. You can later customize this code as per your requirements. $taxonomyName = "product_cat"; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug', ...


0

I think the issue is with the following line of code: $post_thumbnail_id = get_post_thumbnail_id($post->ID); It should be the ID of your $recent variable not $post. $post_thumbnail_id = get_post_thumbnail_id($recent->ID); or $post_thumbnail_id = get_post_thumbnail_id($recent['ID']); and to get a specific size of thumbnail you could do ...


0

Initially, I saw the double and single quotes all jumbled up. This did fix some of what I saw, but I finally had time to test the code you put up. First step, I used var_dump on $recent_posts to make sure I was getting the usable values. Next, I echoed each variable as it was called, to make sure I knew what was being generated. I discovered that this ...


0

Get post thumbnail url with multisite function multisite_thumb_url($pid, $bid){ if(isset($pid) && $pid>0){ if(isset($bid) && $bid>0){ global $wpdb; $curr_blog_id=get_current_blog_id(); $wpdb->set_blog_id( $bid ); $post_thumbnail_id = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->postmeta} ...


1

You can use Adaptive images WordPress plugin. It generates images on the fly and cache them. It gives to settings in admin section in which you can specify your breakpoint ( on which it will generate images ). You can also use Picturefill.WP WordPress plugin.


0

You could use .ajaxComplete, as mentioned by @onetrickpony in http://wordpress.stackexchange.com/a/36597/57034, except do it globally on document, as mentioned in http://api.jquery.com/ajaxcomplete/, then filter based on action: add_action( 'admin_print_footer_scripts', function () { ?> <script type="text/javascript"> jQuery(function ...


0

I found the problem. For some reason it was a JPEG file's issue. I recreated all the JPEGs and now it generates the thumbnails...


0

I would try a couple of things: Check the image itself, I've come across jpg images that have malformed headers so on my linux based desktop (Xubuntu) i can't open them in Thunar/Ristretto but can open them in GIMP. Try re-uploading (after a DB/File backup) the WordPress core files again, perhaps one of them was corrupted during upload/unpacking?


1

If this is still a problem, then you can find my answer on wordpress.org's support forum, it might help: wordpress.org/support/topic/resize-failure-on-some-images-with-odd-message This is a part of a code from the jQuery library, to be specific this part is responsible for handling callbacks. It is displayed, because the reponse from wordpres is ...


0

I think from your question you might want to look at adding a new thumbnail image size into your functions.php add_image_size( $name, $width, $height, $crop ); https://codex.wordpress.org/Function_Reference/add_image_size You'll then need to regenerate the post thumbnails, as you've added a new image size, there is a plugin called "Regenerate Thumbnails" ...


0

I figured out it was because of an script that was delivered with the Options Framework. There was a little piece of code in my functions.php which caused wrong javascript to be loaded. When you are having the same problem, be sure to search for something like wp_enqueue_media(); or something of the following script, comment out and try to upload a ...


-1

You need to add support for thumbnails in your theme. So, put this in your theme files: function custom_theme_setup() { add_theme_support( $feature, $arguments ); } add_action( 'after_setup_theme', 'custom_theme_setup' ); This enables the thumbnail/feature image support for all post types in your current theme including normal posts and pages.


1

This function will generate an image by temporarily registering an image size, generating the image (if necessary) and the removing the size so new images will not be created in that size. function lazy_image_size($image_id, $width, $height, $crop) { // Temporarily create an image size $size_id = 'lazy_' . $width . 'x' .$height . '_' . ((string) ...



Top 50 recent answers are included