https://github.com/daggerhart/remote-url-summarizer
WordPress plugin that grabs remote urls found in posts or comments and unfurls them. Sideload images and summarize html.
https://github.com/daggerhart/remote-url-summarizer
unfurl wordpress
Last synced: 2 months ago
JSON representation
WordPress plugin that grabs remote urls found in posts or comments and unfurls them. Sideload images and summarize html.
- Host: GitHub
- URL: https://github.com/daggerhart/remote-url-summarizer
- Owner: daggerhart
- Created: 2015-05-27T15:16:28.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-29T19:51:13.000Z (over 10 years ago)
- Last Synced: 2025-03-02T16:50:40.935Z (over 1 year ago)
- Topics: unfurl, wordpress
- Language: PHP
- Homepage:
- Size: 184 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Remote URL Summarizer
When a post or comment is saved, this plugin will scan it for remote (external) urls, and grab data about them. When viewing the post or comment, this plugin will create a summary of the remote urls and display it beneath the content. If the remote url is determined to be an image by its mimetype, it will be sideloaded into the WordPress media library and attached to the post.
## Features
* Per post_type support
* Comments support
* Extendable through hooks
* Sideload (download) remote images into WordPress media library
* Select image size to be shown in summary
### Hooks
**Filters**
* `rurls-settings-fields` - Extend the options page to include additional settings
* `rurls-pre-fetch` - Alter the found urls before fetching data
* `rurls-post-fetch` - Alter the fetched data before saving as post/comment meta
* `rurls-mime-types` - Provide support for additional mime types
### Supported Mime Types
Included in this plugin is the ability to summarize the following mimetypes.
* image/jpeg
* image/gif
* image/png
* text/html
### Adding Mime Type Support
You can provide additional mime types for summarization using the `rurls-mime-types` filter.
Simple example:
```php
// provide an additional mime type to the summarizer, along with its fetch and display callbacks
function my_mime_types( $mime_types ){
$mime_types['image/bmp'] = array(
'title' => __('BMP'),
'fetch_callback' => 'my_fetch_callback', // callable string or array
'display_callback' => 'my_display_callback', // callable string or array
);
return $mime_types;
}
add_filter('rurls-mime-types', 'my_mime_types');
// fetch_callback needs to loop through the urls and return an array of data
function my_fetch_callback( $urls ){
$images = array();
$post_id = get_the_ID() ? get_the_ID() : 0;
foreach( $urls as $original_url ){
// attempt to grab the image
$image_id = rurls_media_sideload_image( $original_url, $post_id, null, 'id');
if ( ! is_wp_error( $image_id ) ) {
$images[ $image_id ] = $original_url;
}
}
return $images;
}
// display_callback needs to loop through the data array and return a string of html
function my_display_callback( $data ){
$output = '';
foreach( $data as $id => $original_url ){
$output.= wp_get_attachment_image( $id, $this->settings['image_size'] );
}
return $output;
}
```