Images are not retrieved with relative links
-
Currently images with relative links are not tracked by this plugin.
Additionally retrieval of src-attributes in img-tags is not according to documentation in DOMNode.
You can fix both by replacing the following two lines in
isc.class.php
:@ 189,189 - $srcs[] = $node->getAttribute('src'); + $srcs[] = $node->attributes->getNamedItem('src')->textContent; @ 222,222 - $query = sprintf("SELECT ID FROM {$wpdb->posts} WHERE post_type='attachment' AND guid = \"http:%s\" OR guid = \"https:%s\" LIMIT 1", $newurl, $newurl ); + $query = sprintf('SELECT ID FROM %1$s WHERE post_type="attachment" AND guid LIKE "%%%2$s" LIMIT 1', $wpdb->posts, $newurl );
That should take care of the issue.
Additionally I’Ve seen that wordpress-galleries are not taken into account. I’ve solved that by adding the following code to my
function.php
but you might want to include that into the plugin at some time:add_filter('isc_images_in_posts_simple', function($imageUrls, $postId){ $postContent = ''; if (! empty($_REQUEST['content'])) { $postContent = stripslashes($_REQUEST['content']); } if (! preg_match_all('/\[gallery([^\]]+)\]/m', $postContent, $results, PREG_SET_ORDER)) { return $imageUrls; } foreach ($results as $result) { if (! preg_match('/ids="([^"]+)"/m', $result[1], $ids)) { continue; } $imageUrls = array_merge($imageUrls, array_map(function ($id) { return wp_get_attachment_url(trim($id)); }, explode(',', $ids[1]))); } return $imageUrls; }, 10, 2);
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Images are not retrieved with relative links’ is closed to new replies.