New answers tagged

0

Try adding this to your functions.php - it will wrap the image in the div you want. function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) { return '<div class="post-page-image" id="image-'.$id.'">'.$html.'</div>'; } add_filter('image_send_to_editor', 'filter_image_send_to_editor', 10, 8);


0

I've actually forgotten to create the function for uploading and attaching images. I've found the correct method into another question here Uploading Multiple Attachments From Front-End With A Description.


0

Modified for the latest WordPress version. Full guide available here : https://phpbits.net/wordpress-replace-user-uploaded-large-images-automatically/ /* * Remove Original Uploaded images * retain large size image */ add_filter('wp_generate_attachment_metadata','phpbits_replace_uploaded_image'); function phpbits_replace_uploaded_image($image_data) { // ...


0

Florian's answer is probably your best bet because it gives the author the most control as to how the images are aligned so that would be my first answer. However, if you don't trust your authors to align the images themselves then we'll have to go another route. Unfortunately for the reasons you stated above, it doesn't look like we can use the :nth-child ...


0

Have the writer use the left/right align functionality built into the WordPress text editor. The editor adds alignleft or alignright classes to the aligned images. Way more info can be found in the WordPress codex.


0

Alternative solution here: http://pixert.com/blog/cropping-post-featured-thumbnails-from-top-instead-of-center-in-wordpress-with-native-cropping-tool/ Just add this code to functions.php, then use "Regenerate Thumbnails" plugin (https://wordpress.org/plugins/regenerate-thumbnails/): function px_image_resize_dimensions( $payload, $orig_w, $orig_h, $dest_w, ...


0

Here's the relevant part of your code that should work: // This will make a URL like http://yoursite.com/path/to/fallback.png $fallback_image = site_url( '/path/to/fallback.png' ); $fallback_image = "<img src='{$fallback_image}' />"; foreach( $recent_posts as $recent ){ echo '<div class="sidebar-entries">'; $featured_image = ...


0

Following are the two errors at console Failed to load resource: the http://www.jeremyscircle.org/favicon.ico server responded with a status of 404 (Not Found) Failed to load resource: the http://www.jeremyscircle.org/en_US/gallery/ server responded with a status of 500 (Internal Server Error) Failed to load resource: the server responded with a status ...


2

In general I wouldn't recommend modifying the original uploaded image files, just in case we might need to re-generate intermediate sizes. But let's see if it's possible :-) We can in general let WordPress choose the image editor, that depends on modules like GD or Imagick, through: $editor = wp_get_image_editor( $file ); but this can return an WP_Error ...


0

There is a plugin called Resize Image After Upload: <?php /* Plugin Name: Resize Image After Upload Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/ Description: Simple plugin to automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options ...


0

This answer could help you: http://wordpress.stackexchange.com/a/69287/92649 You would need to upload your image at a higher resolution than "large" to have that effect, though


0

Just gong to post the answer here too. @Dan linked to another question that had the answer. Here's some documentation on the new responsive images feature: Responsive Images in WordPress 4.4 The default max-size that will go into a srcset is 1600px wide. So if you plan on using images that are bigger than that, you need to change that. It can be changed ...


0

I had to code an external program, I can't see any other way. I used Java JDBC in my case. Query: SELECT p.post_title, m.meta_value FROM wp_term_taxonomy tt INNER JOIN wp_term_relationships tr on tt.term_taxonomy_id = tr.term_taxonomy_id inner join wp_posts p on p.ID = tr.object_id inner join wp_posts p2 on p.ID = p2.post_parent inner join wp_postmeta m on ...


1

Your first function get_images_from_media_library() only returns images guid, I'd suggest to extend it by returning all image datas : function get_images_from_media_library() { $args = array( 'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => 6, ...


0

There is little difference, by default crop is set to false. function add_image_size( $name, $width = 0, $height = 0, $crop = false ) { global $_wp_additional_image_sizes; $_wp_additional_image_sizes[ $name ] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => $crop, ); } And also ...


0

The error is being generated on image attachment pages, so this is most likely a bot. But I added a check before the shutter speed is converted to a fraction: $imgmeta = wp_get_attachment_metadata( $id ); $imgShutter = $imgmeta['image_meta']['shutter_speed']; // Convert the shutter speed retrieve from ...


2

shutter speed is one of the exif data wordpress tries to extract from images when uploaded. If the image do not contain the info it will be zero, hence your division by zero error. Somewhere before that code you should check if the image even needs to go there. If it is not a photo then probably not.


0

Even that you're sure that all your images have the 'shutter_speed' declared and more than 0 (although your error report is saying that some does not have), it's a good practice to validate it. Try including a new parent if like this: if ( isset($imgmeta['image_meta']['shutter_speed']) && (intval($imgmeta['image_meta']['shutter_speed'])>0) ) { ...


0

No, the wp_get_attachment_image_src function calls image_downsize, which in turn calls image_get_intermediate_size itself. It doesn't cause generation of the images, it is simply getting the relevant images from the meta and choosing the correct one to use.


2

It's already in the docs. Try this: <?php $image = get_field('image'); if( !empty($image) ): ?> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> <?php endif; ?> For easier debugging, try this: var_dump($image); to print out the $image variable to know what is in $image. You can also put ...


1

Unfortunately @Patrick's answer breaks the srcset functions introduced in WP 4.4. Fortunately, we just need to add two additional functions! First, we need to temporarily re-introduce all of the registered thumbnail sizes to the image metadata so they can be considered: function bi_wp_calculate_image_srcset_meta($image_meta, $size_array, $image_src, ...


0

There is likely a javascript error in /js/custom.js Look for the line: $( 'a[href*=#]:not([href=#])' ).click( function() { Change it to: $( 'a[href*="#"]:not([href="#"])' ).click( function() { You'll probably still have quirks with the page builder and various other functions until a theme update is released. Or, revert to the previous default version of ...


3

Register a collection post type to represent a single collection. You'll get permalinks and rewrite rules to resolve the requests for free. Insert a new collection post for a user when they create a collection, and save the chosen post IDs as an array in post meta. You can pass that array directly as post__in argument in a WP_Query instance to load the ...


1

The problem is that you are using functions from GD library to manipulate images, not functions from WordPress Image API (WP_Image_Editor class). So, WordPress things doesn't apply to the generated image by your code. WordPress Image API uses ImageMagick if available, otherwise it uses GD library. In order to keep EXIF data: If GD library is used, you ...


0

I think you might have to modify the plugin, fork it, if you like the rest of it's functionality. Then add functionality that when you "favourite" a post/image, instead of adding it to your favourites you get a list which collection you want to add it to. All of these collections could have their own url like www.mysite.com/user/collections/collection-name ...


1

I just worked out why it wasn't working. In order for WordPress to generate the srcset and size attributes for images in the_content, it must have a class associated with it indicating the image attachment id (for example, 'wp-image-41'). This is automatically attached to the image when it is inserted via the editor. Unfortunately, in my older posts, all ...


1

From the Dashboard of your WordPress website, go to Media > Library You will see all of your images there. Select the image which one you want to update, and click "Edit". The "Edit Media" page will open. Scroll down to the bottom of this page, you will be found few input boxes to provide the Caption, Alternative Text and the Description of your image ...


-1

You should not assume that image related metadata survives the wordpress image manipulation. As you found out it depends on the image manipulation library installed on the server, and actually in version 4.5 the aim would be to strip some of it as noted here https://make.wordpress.org/core/2016/03/12/performance-improvements-for-images-in-wordpress-4-5/. If ...


0

The issue I was having was with some conflicting code I had in my functions file (see below). I usually use this code to remove width/height attributes from being hard-coded into the element in the content area. Removing these somehow appears to mess up the new responsive image implementation in WordPress though. As soon as I removed this code, the ...


1

The WP_Query class can match IDs as well as search terms. An idea would be to use the pre_get_posts action to detect if the search term is numeric and, if it is, set the query to work with attachments while passing the search as the ID. function wpse223307_allow_search_by_attachment_id( $query ) { //Only alter the query if we are in a search screen,... ...


1

I see multiple messages about images and some script blocked in Chrome with (blocked:mixed-content) reason. Which basically means it doesn't like unsecure http resources in secure https site. WordPress doesn't handle this particularly well. It is designed to use absolute URLs and they tend to end up hardcoded in content and such. You would have to: ...


0

So what's wrong with adding in the attributes as Mark is saying? <?php $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url( $thumb,'full' ); $image = aq_resize( $img_url, 150, 200, true, true, true ); ?> <img src="<?php if($image) { echo esc_url($image); } else { echo catch_that_image();} ?>" width="150" height="200" ...


0

You are right that global $post is not set inside the function. Because it is Ajax callback and there is no loop. However Ajax call is sending post ID which you can retrieve as $_POST['post_id'] inside the function. Please note: In callback function arguments $url is not the image URL. It is anchor tag URL. So if someone choose none, attachment page or ...


2

Yes, this is trivial in WordPress. Whenever you upload image WP keeps original file and generates additional sizes from it. Several of the sizes are built–in (see Settings > Media > Image sizes) and any additional ones can be added with add_image_size(). So when you develop your own theme as part of the process you: Determine image size you need. ...


1

while googling about the same issue I came upon your question and a similar question from the Wordpress forums. You can control the output of the generated code via the image_send_to_editor filter like this: function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) { $html = sprintf('<a href="#" ...



Top 50 recent answers are included