Skip to content

Commit

Permalink
add the ability to download and paste a GIF file rather than just the…
Browse files Browse the repository at this point in the history
… URL
  • Loading branch information
chad1008 committed Aug 13, 2023
1 parent 5314461 commit 64bbeac
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Gifomattic uses three modifier keys: CMD, SHIFT, and CTRL.

**CTRL** is used exclusively for permanently deleting GIFs from the trash. It serves no other function, to decrease the risk of accidental deletions.

**OPTION** is used to download a GIF to your computer and then paste it into whatever app currently has focus. This is useful for apps or services that don't unfurl or animate GIF URLs.

## Explore Mode
You can explore your library using the **CMD** modfier. When used on a GIF, you'll be shown the name and URL of the GIF, and can preview the GIF by using the **CMD** modifier again. You'll also see how often the GIF has been shared, the date that you first saved it, and any tags that are assigned to it.

Expand Down
2 changes: 1 addition & 1 deletion src/classes/class-gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function generate_icon() {
// Determine image type based on file extension (not infallible but should be good for most cases)
$image_type = exif_imagetype( $this->new_props['url'] );

// Create a new file from the url, read it's dimensions
// Create a new file from the url, read its dimensions
if ( $image_type == 1 ) {
$original_gif = imagecreatefromgif( $this->new_props['url'] );
} elseif ( $image_type == 2 ) {
Expand Down
18 changes: 18 additions & 0 deletions src/classes/class-workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ public function the_tag( $the_tag, $input ) {
'original_input' => $input,
),
),
'option' => array(
'subtitle' => 'Download and paste a random "' . $the_tag->name . '" GIF',
'variables' => array(
'next_step' => 'download',
'item_id' => $the_tag->id,
'item_id' => $the_tag->id,
'item_type' => 'tag',
),
),

),
);
}
Expand Down Expand Up @@ -287,6 +297,14 @@ public function the_gif( $the_gif, $input, $mode ) {
'original_input' => $original_input,
),
),
'option' => array(
'subtitle' => 'Download and paste this GIF',
'variables' => array(
'next_step' => 'download',
'item_id' => $the_gif->id,
'item_type' => 'gif',
),
),
),
);
}
Expand Down
12 changes: 12 additions & 0 deletions src/download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

// Set the query input to the ID passed in by Alfred
$url = $argv[1];

$local_file = $_SERVER['alfred_workflow_data'] . '/staged_gif.gif';

$image = file_get_contents( $url );
file_put_contents( $local_file ,$image );

// Set the output to the file path so the next script can easily grab it
echo $local_file;

0 comments on commit 64bbeac

Please sign in to comment.