Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly imported images have the incorrect id in the class attribute #129

Open
mukeshpanchal27 opened this issue Jul 6, 2022 · 0 comments

Comments

@mukeshpanchal27
Copy link
Member

Actually, this issue arises in the performance repo #339.

If we import unit test data from https://codex.wordpress.org/Theme_Unit_Test into any existing site, the actual image is different from the image tag class id wp-image-%image_ID.

For example, If we have an attachment id 10 for an image but when we import the unit test that image will get the last database insert id called 100. In this case, the image class still shows class="wp-image-10" instead of class="wp-image-100".

WP Import changes the image URL in https://github.com/WordPress/wordpress-importer/blob/master/src/class-wp-import.php#L1269-L1280 function with an update query.

$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url ) );

It should be fixed so others can use the accurate image id from the class for newly imported attachments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants