feat: added imageSize (preview, full) parameter & bumped version numbers
This commit is contained in:
parent
5860a9ad26
commit
5f6098b030
@ -37,6 +37,7 @@ Place the following shortcode right into the page. Either as shortcode block or
|
||||
| onlyPinned | false | onlyPinned="true" | Show only pinned statuses |
|
||||
| onlyMedia | false | onlyMedia="true" | Show only statuses containing media |
|
||||
| preserveImageAspectRatio | false | preserveImageAspectRatio="true" | Preserve image aspect ratio |
|
||||
| imageSize | "preview" | imageSize="full" | Load small sized preview images or full size high quality images |
|
||||
| tagged | false | tagged="tagname" | Show only statuses that are tagged with given tag name (no #!) |
|
||||
| linkTarget | "_self" | linkTarget="_blank" | Target for all links |
|
||||
| showPreviewCards | true | showPreviewCards="false" | Show preview cards |
|
||||
|
@ -19,7 +19,7 @@
|
||||
// set a default instance
|
||||
// can still be overriden in shortcode
|
||||
// plugin will show a warning if no default is set and instance is omitted in shortcode
|
||||
//define('INCLUDE_MASTODON_FEED_DEFAULT_INSTANCE', 'example.org');
|
||||
define('INCLUDE_MASTODON_FEED_DEFAULT_INSTANCE', 'example.org');
|
||||
|
||||
// Maximum number of statuses
|
||||
define('INCLUDE_MASTODON_FEED_LIMIT', 20);
|
||||
@ -43,6 +43,9 @@
|
||||
// can be overridden in shortcode
|
||||
define('INCLUDE_MASTODON_FEED_PRESERVE_IMAGE_ASPECT_RATIO', true);
|
||||
|
||||
// load small sized preview images or full size high quality images
|
||||
define( 'INCLUDE_MASTODON_FEED_IMAGE_SIZE', 'preview' );
|
||||
|
||||
// only tagged statuses
|
||||
// tag name without leading #, case insensitive
|
||||
define('INCLUDE_MASTODON_FEED_TAGGED', 'tagname');
|
||||
|
36
plugin.php
36
plugin.php
@ -48,6 +48,10 @@ $constants = [
|
||||
'key' => 'INCLUDE_MASTODON_FEED_PRESERVE_IMAGE_ASPECT_RATIO',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'key' => 'INCLUDE_MASTODON_FEED_IMAGE_SIZE',
|
||||
'value' => 'preview',
|
||||
],
|
||||
[
|
||||
'key' => 'INCLUDE_MASTODON_FEED_TAGGED',
|
||||
'value' => false,
|
||||
@ -361,24 +365,21 @@ function init_scripts() {
|
||||
let mediaElem = mastodonFeedCreateElement('div', media.type);
|
||||
if('image' == media.type) {
|
||||
let mediaElemImgLink = mastodonFeedCreateElement('a');
|
||||
let imageUrl = media.url;
|
||||
if('full' === options.imageSize && null !== media.remote_url) {
|
||||
imageUrl = media.remote_url;
|
||||
}
|
||||
else if(null !== media.preview_url) {
|
||||
imageUrl = media.preview_url;
|
||||
}
|
||||
mediaElemImgLink.href = status.url;
|
||||
if(null === media.remote_url) {
|
||||
mediaElemImgLink.style.backgroundImage = 'url("' + media.preview_url + '")';
|
||||
}
|
||||
else {
|
||||
mediaElemImgLink.style.backgroundImage = 'url("' + media.remote_url + '")';
|
||||
}
|
||||
mediaElemImgLink.style.backgroundImage = 'url("' + imageUrl + '")';
|
||||
if(null !== media.description) {
|
||||
mediaElem.title = media.description;
|
||||
}
|
||||
if(options.preserveImageAspectRatio) {
|
||||
let mediaElemImgImage = mastodonFeedCreateElement('img');
|
||||
if(null === media.remote_url) {
|
||||
mediaElemImgImage.src = media.preview_url;
|
||||
}
|
||||
else {
|
||||
mediaElemImgImage.src = media.remote_url;
|
||||
}
|
||||
mediaElemImgImage.src = imageUrl;
|
||||
mediaElemImgLink.appendChild(mediaElemImgImage);
|
||||
}
|
||||
mediaElem.appendChild(mediaElemImgLink);
|
||||
@ -479,7 +480,6 @@ function init_scripts() {
|
||||
|
||||
const mastodonFeedRenderStatuses = function(statuses, rootElem, options) {
|
||||
if(statuses.length < 1) {
|
||||
console.log(options);
|
||||
rootElem.innerHTML = options.text.noStatuses;
|
||||
}
|
||||
else {
|
||||
@ -594,11 +594,13 @@ function init_scripts() {
|
||||
const rootElem = document.getElementById(elementId);
|
||||
rootElem.innerHTML = '';
|
||||
<?php if(true === INCLUDE_MASTODON_FEED_DEBUG) : ?>
|
||||
console.log("<?php echo __NAMESPACE__; ?>", url);
|
||||
console.log("<?php echo __NAMESPACE__; ?>", 'url', url);
|
||||
console.log("<?php echo __NAMESPACE__; ?>", 'elementId', elementId);
|
||||
console.log("<?php echo __NAMESPACE__; ?>", 'options', options);
|
||||
<?php endif; ?>
|
||||
if (xhr.status === 200) {
|
||||
<?php if(true === INCLUDE_MASTODON_FEED_DEBUG) : ?>
|
||||
console.log("<?php echo __NAMESPACE__; ?>", xhr.response);
|
||||
console.log("<?php echo __NAMESPACE__; ?>", 'response', xhr.response);
|
||||
<?php endif; ?>
|
||||
if(options.excludeConversationStarters && statuses.length > 0) {
|
||||
const filteredStatuses = [];
|
||||
@ -625,7 +627,7 @@ function init_scripts() {
|
||||
}
|
||||
else {
|
||||
<?php if(true === INCLUDE_MASTODON_FEED_DEBUG) : ?>
|
||||
console.log("<?php echo __NAMESPACE__; ?>", xhr);
|
||||
console.log("<?php echo __NAMESPACE__; ?>", 'response error', xhr);
|
||||
<?php endif; ?>
|
||||
rootElem.appendChild(document.createTextNode(xhr.response.error));
|
||||
}
|
||||
@ -651,6 +653,7 @@ function display_feed($atts) {
|
||||
'onlypinned' => filter_var(esc_html(INCLUDE_MASTODON_FEED_ONLY_PINNED), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
'onlymedia' => filter_var(esc_html(INCLUDE_MASTODON_FEED_ONLY_MEDIA), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
'preserveimageaspectratio' => filter_var(esc_html(INCLUDE_MASTODON_FEED_PRESERVE_IMAGE_ASPECT_RATIO), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
'imagesize' => INCLUDE_MASTODON_FEED_IMAGE_SIZE,
|
||||
'tagged' => INCLUDE_MASTODON_FEED_TAGGED,
|
||||
'linktarget' => INCLUDE_MASTODON_FEED_LINKTARGET,
|
||||
'showpreviewcards' => filter_var(esc_html(INCLUDE_MASTODON_FEED_SHOW_PREVIEWCARDS), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
@ -720,6 +723,7 @@ function display_feed($atts) {
|
||||
showPreviewCards: <?php echo (filter_var( $atts['showpreviewcards'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
|
||||
excludeConversationStarters: <?php echo (filter_var( $atts['excludeconversationstarters'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
|
||||
preserveImageAspectRatio: <?php echo (filter_var( $atts['preserveimageaspectratio'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
|
||||
imageSize: "<?php echo ( "full" === $atts['imagesize'] ? "full" : "preview" ); ?>",
|
||||
content: {
|
||||
hideStatusMeta: <?php echo (filter_var( $atts['hidestatusmeta'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
|
||||
hideDateTime: <?php echo (filter_var( $atts['hidedatetime'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>
|
||||
|
10
readme.txt
10
readme.txt
@ -3,9 +3,9 @@ Contributors: wolfgang101
|
||||
Donate link: https://www.buymeacoffee.com/w101
|
||||
Tags: mastodon, status, feed
|
||||
Requires at least: 6.0
|
||||
Tested up to: 6.5
|
||||
Tested up to: 6.7
|
||||
Requires PHP: 7.4
|
||||
Stable tag: 1.9.4
|
||||
Stable tag: 1.9.5
|
||||
License: Expat License
|
||||
License URI: https://directory.fsf.org/wiki/License:Expat
|
||||
|
||||
@ -56,6 +56,9 @@ Show only statuses containing media (Default: false)
|
||||
* **preserveImageAspectRatio**
|
||||
Preserve image aspect ratio (Default: false)
|
||||
|
||||
* **imageSize**
|
||||
Load small sized preview images or full size high quality images (Default: preview, full)
|
||||
|
||||
* **tagged**
|
||||
Show only statuses that are tagged with given tag name (Default: false)
|
||||
No leading #, case insensitive, e.g.: tagged="tagname"
|
||||
@ -148,6 +151,9 @@ Use the following URL to get your ID:
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.9.5 =
|
||||
* added option to load large image versions instead of medea previews (preview still default)
|
||||
|
||||
= 1.9.4 =
|
||||
* added option to hide status meta information and date/time (thank you @PaulKingtiger@dice.camp)
|
||||
* added tag support - you can now embed tag feeds (thank you @martin@openedtech.social)
|
||||
|
Loading…
x
Reference in New Issue
Block a user