feat: added imageLink parameter
This commit is contained in:
parent
5f6098b030
commit
c75582ca6b
@ -38,6 +38,7 @@ Place the following shortcode right into the page. Either as shortcode block or
|
||||
| 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 |
|
||||
| imageLink | "status" | imageLink="image" | Link image to status or image |
|
||||
| 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 |
|
||||
|
@ -46,6 +46,9 @@
|
||||
// load small sized preview images or full size high quality images
|
||||
define( 'INCLUDE_MASTODON_FEED_IMAGE_SIZE', 'preview' );
|
||||
|
||||
// link image to status or image
|
||||
define( 'INCLUDE_MASTODON_FEED_IMAGE_LINK', 'status' );
|
||||
|
||||
// only tagged statuses
|
||||
// tag name without leading #, case insensitive
|
||||
define('INCLUDE_MASTODON_FEED_TAGGED', 'tagname');
|
||||
|
19
plugin.php
19
plugin.php
@ -52,6 +52,10 @@ $constants = [
|
||||
'key' => 'INCLUDE_MASTODON_FEED_IMAGE_SIZE',
|
||||
'value' => 'preview',
|
||||
],
|
||||
[
|
||||
'key' => 'INCLUDE_MASTODON_FEED_IMAGE_LINK',
|
||||
'value' => 'status',
|
||||
],
|
||||
[
|
||||
'key' => 'INCLUDE_MASTODON_FEED_TAGGED',
|
||||
'value' => false,
|
||||
@ -366,18 +370,21 @@ function init_scripts() {
|
||||
if('image' == media.type) {
|
||||
let mediaElemImgLink = mastodonFeedCreateElement('a');
|
||||
let imageUrl = media.url;
|
||||
if('full' === options.imageSize && null !== media.remote_url) {
|
||||
if('full' === options.images.size && null !== media.remote_url) {
|
||||
imageUrl = media.remote_url;
|
||||
}
|
||||
else if(null !== media.preview_url) {
|
||||
imageUrl = media.preview_url;
|
||||
}
|
||||
mediaElemImgLink.href = status.url;
|
||||
if('image' === options.images.link) {
|
||||
mediaElemImgLink.href = media.remote_url ?? media.url;
|
||||
}
|
||||
mediaElemImgLink.style.backgroundImage = 'url("' + imageUrl + '")';
|
||||
if(null !== media.description) {
|
||||
mediaElem.title = media.description;
|
||||
}
|
||||
if(options.preserveImageAspectRatio) {
|
||||
if(options.images.preserveImageAspectRatio) {
|
||||
let mediaElemImgImage = mastodonFeedCreateElement('img');
|
||||
mediaElemImgImage.src = imageUrl;
|
||||
mediaElemImgLink.appendChild(mediaElemImgImage);
|
||||
@ -654,6 +661,7 @@ function display_feed($atts) {
|
||||
'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,
|
||||
'imagelink' => INCLUDE_MASTODON_FEED_IMAGE_LINK,
|
||||
'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),
|
||||
@ -722,12 +730,15 @@ function display_feed($atts) {
|
||||
linkTarget: "<?php echo filter_var( $atts['linktarget'], FILTER_UNSAFE_RAW ); ?>",
|
||||
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"); ?>
|
||||
},
|
||||
images: {
|
||||
preserveImageAspectRatio: <?php echo (filter_var( $atts['preserveimageaspectratio'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
|
||||
size: "<?php echo ( "full" === $atts['imagesize'] ? "full" : "preview" ); ?>",
|
||||
link: "<?php echo ( "image" === $atts['imagelink'] ? "image" : "status" ); ?>",
|
||||
},
|
||||
text: {
|
||||
boosted: "<?php echo esc_js( $atts['text-boosted'] ); ?>",
|
||||
noStatuses: "<?php echo esc_html( $atts['text-nostatuses'] ); ?>",
|
||||
|
@ -59,6 +59,9 @@ Preserve image aspect ratio (Default: false)
|
||||
* **imageSize**
|
||||
Load small sized preview images or full size high quality images (Default: preview, full)
|
||||
|
||||
* **imageLink**
|
||||
Link image to status or image (Default: status, image)
|
||||
|
||||
* **tagged**
|
||||
Show only statuses that are tagged with given tag name (Default: false)
|
||||
No leading #, case insensitive, e.g.: tagged="tagname"
|
||||
@ -152,7 +155,8 @@ 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)
|
||||
* added option to either display smaller image media attachment previews (default) or large image versions
|
||||
* added option to point image media attachment links to either status (default) or image
|
||||
|
||||
= 1.9.4 =
|
||||
* added option to hide status meta information and date/time (thank you @PaulKingtiger@dice.camp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user