Skip to content

Commit

Permalink
Support for animated gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
GuLinux committed Aug 30, 2017
1 parent 059e8f7 commit 6fac94e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.0.3
## 30/08/2017

1. [](#new)
* New parameter `animated=true` to display gif as animated when using regular, real and hd formats

# v1.0.2
## 28/08/2017

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This is a list for each shortcode.
* `image_class`: extra css classes for the main image html tag.
* `image_lightbox_class`: extra css classes for the main lightbox html tag.
* `revision`: image revision to load. It can be "final", "original", or an uppercase letter corresponding to the revision letter of the astrobin technical page (A, B, C, etc).
* `animated`: set to true if you want to display gif animation instead of the preview static image.
* astrobin-collection
* `collection_title_tag`: HTML tag to use for the collection title.
* `collection_description_tag`: HTML tag to use for the collection description.
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Astrobin
version: 1.0.2
version: 1.0.3
description: "This plugin provides astrobin shortcodes for images and galleries"
icon: picture-o
author:
Expand Down
3 changes: 2 additions & 1 deletion classes/AstrobinCommons.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ static function defaultParams() {
'format_image_lightbox' => 'hd',
'collection_title_tag' => 'h3',
'collection_description_tag' => 'h5',
'revision' => 'final'
'revision' => 'final',
'animated' => false
];
}
}
8 changes: 6 additions & 2 deletions classes/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function datetaken() {
return NULL;
}

public function url($format, $revision_type="final") {
public function url($format, $revision_type="final", $animated=false) {
$revision_obj = NULL;
if($revision_type == "final") {
foreach($this->revisions as $revision) {
Expand All @@ -53,7 +53,11 @@ public function url($format, $revision_type="final") {
}
}
}
return $revision_obj->{'url_' . $format};
$url = $revision_obj->{'url_' . $format};
if($animated) {
$url .= '?animated';
}
return $url;
}

public function astrobinPage() {
Expand Down
4 changes: 2 additions & 2 deletions templates/partials/astrobin-image-lightbox.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<figcaption>
<h4 class="astrobin-lightbox-title">{{ image.title() }}</h4>
<div class="astrobin-lightbox-links">
<a href="{{ image.url('real', params['revision'] ) }}" target='_blank'><i class="fa fa-picture-o" aria-hidden="true"></i> Original version</a>
<a href="{{ image.url('real', params['revision'], params['animated'] ) }}" target='_blank'><i class="fa fa-picture-o" aria-hidden="true"></i> Original version</a>
<a href="{{ image.astrobinPage() }}" target='_blank'><i class="fa fa-external-link" aria-hidden="true"></i> Astrobin technical details page</a>
</div>
</figcaption>
<img src="{{ image.url(params['format_image_lightbox'], params['revision']) }}">
<img src="{{ image.url(params['format_image_lightbox'], params['revision'], params['animated']) }}">
<div class="astrobin-lightbox-description">
{{ image.description()|replace({"\n": "<br>"}) }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/partials/astrobin-image.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a href="#" data-featherlight="#lightbox-{{ image.id() }}" class="astrobin-image {{params['image_class']}}">
<figure>
<img src="{{ image.url(params['format_image'], params['revision']) }}">
<img src="{{ image.url(params['format_image'], params['revision'], params['animated']) }}">
<figcaption>{{ image.title() }}</figcaption>
</figure>
</a>
Expand Down

0 comments on commit 6fac94e

Please sign in to comment.