danieltotherescue
Forum Replies Created
-
Hey @dglingren,
Thanks for the update @dglingren !
I see on the other ticket that you linked a downloadable zip for the other ticket. Where can I find the development version in zip format?
Many thanks
Forum: Plugins
In reply to: [Custom Post Type Permalinks] Remove the default posttype slug from URL@toro_unit I am also interested to change the with_front value to false. I currently have the following code in my PostTypes.php file in the appropriate $arg values:
'rewrite' => array ( 'with_front' => false )
Any pointers or other things that can be done to set the default value of with_front = false?
Thanks for your reply @dglingren
Since my last message, I have been trying a few things which might be of assistance in your update (or maybe not ??
I tried adding this function to the end of the functions.php file for the child theme being used:
/** * Add attachment ID class to images * * @param array $attr Array of attributes. * @param object $attachment Attachment Post object, instance of WP_Post class. * @return array Image attributes array. */ function lwp_attachment_id_class( $attr, $attachment ) { $class_attr = isset( $attr['class'] ) ? $attr['class'] : ''; $has_class = preg_match( '/wp\-image\-[0-9]+/', $class_attr, $matches ); // Check if the image is missing the class if ( !$has_class ) { $class_attr .= sprintf( ' wp-image-%d', $attachment->ID ); // Use ltrim to to remove leading space if necessary $attr['class'] = ltrim( $class_attr ); } return $attr; } add_filter( 'wp_get_attachment_image_attributes', 'lwp_attachment_id_class', 10, 2 );
My desired result by adding this function was to have the ID classes be added to each of the images. However this only resulted in the Media -> Assistant menu not populating.
one extra point is that the images on the site were added in such a way that they are not categorized by date but simply in the main wp-content/uploads folder/filename.jpg format. If this is the case, would that make finding them and adding the class=”wp-image-<id#>” more difficult?
@dglingren I’m not sure what I was looking for as far as “table pages” to be honest, but the page loaded fine.
I’m actually hoping to use the tool on multiple sites, each with anywhere from 20 – 150 images (varies quite a bit). But since the images were loaded in a non-uniform fashion, the majority lack the wp-image class, so I’d like to get that sorted if at all possible.
In this test site’s case, there are about 55 images in the Media Library.
About the recommended approach to match the path and file name values of the items’ attached files, were you suggesting that after taking the steps you laid out, how would I match and add the alt text in such a way?
Thanks!
@dglingren thanks for your quick reply!
I actually found a workaround by using the Post/Page Insert Image Tag Attribute Modification tool in the Fixit Plugin with the following attributes:
Data Source [+alt_text+] ? Attribute Name alt
This would fit my needs straightaway, but unfortunately in order to work the images seem to need the image class (e.g. class=”wp-image-788″). Most of the images on the sites I am trying to use this on do not have these classes. Is there any way to use the Post/Page Insert Image Tag Attribute Modification on such images without the appropriate image class?
—
As to your above suggestion, I tested it and it works…but only for images with the class. Is there any way with existing plugin functionality to recognize all inserted media library images without the wp-image-<id#> class and add them?@dglingren Thanks for your detailed replies. I’m having the saem issue as @jarjarbinks and @scubarob but am also receiving the message that 0 posts were updated after using the Fixit tool. Here is one such code example from the page which is not being updated with the alt text from the media library:
<article id="MainContent"> <h1>Hot Tubs, Pools, Billiards & Darts Since 1993!</h1> <img style="width: 377px; height: 275px; float: right;" src="https://alt-text-pool-and-cues.pantheonsite.io/wp-content/uploads/Pools-Cues-Pool-Table.jpg" /> <img src="https://alt-text-pool-and-cues.pantheonsite.io/wp-content/uploads/2019/01/8_1547578498-300x169.jpg" width="300" height="169" class="alignnone size-medium wp-image-993" />
and the “error” message received is:
ALT from Item matched 84 posts/pages to 1 attachments and made 0 update(s) in 0 posts/pages. There were 0 error(s).
- This reply was modified 5 years, 10 months ago by danieltotherescue.