Download the PHP package formula21/yourls-qr-thumbnail-plugin-with-preview-redirect without Composer
On this page you can find all versions of the php package formula21/yourls-qr-thumbnail-plugin-with-preview-redirect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download formula21/yourls-qr-thumbnail-plugin-with-preview-redirect
More information about formula21/yourls-qr-thumbnail-plugin-with-preview-redirect
Files in formula21/yourls-qr-thumbnail-plugin-with-preview-redirect
Package yourls-qr-thumbnail-plugin-with-preview-redirect
Short Description A YOURLS Plugin, which integrates a QR Plugin, a Thumbnail Plugin and combines both to make a preview page, which can be seen both before redirect or forced with the preview character.
License MIT
Informations about the package yourls-qr-thumbnail-plugin-with-preview-redirect
Preview and Redirect Plugin - Yourls
Description
When you use short-link like https://sho.rt/mylink
and it redirects to https://www.example.com/redirect-with-shortlink/long-link/my-link
, the user never knows where this redirect. To add a trusty layer over your user, I introduce you to the Preview and Redirect Plugin (with QR Code, Thumbnail Generation, Pre-Preview & Forced-Preview [Complementary]).
Features (A Lot!!)
- [X] Support to generate a thumbnail by adding
.i
to the short-link. - [X] Support for
QR
generation by adding.qr
to end of the short link. - [X] Support for preview and redirection:
- [X] This can be done by adding
~
character to the end of the short-link. (This is an action caused by default) - [X] You can choose to enable/disable automatically preview before redirect for a preset default number of second.
- [X] This can be done by adding
Enabling and Disabling
- If you want to enable the
QR (.qr)
generation, then you need to modify inusers/config.php
, by adding:
By default: The plugin is disabled.
- If you want to enable the
thumbnail (.i) generation plugin
, then you need to modify inusers/config.php
, by adding:
By default: The plugin is disabled.
-
If you choose to customize the preview before redirect, the following should be noted:
-
Auto Preview before redirect by default is DISABLED. To enable use the code below in
users/config.php
. - You can also alter the wait time to show the preview page, before automatically redirecting.
The constant
F21_PREVIEW_TIME
is only effective ifF21_PREVIEW_REDIRECT
istrue
.Default: The constant of time has a value
0
, which means infinite waiting time. If we do not find a valid integer. Then we consider the same to be0
by default.Range: The valid range of the time is between [0, 60] both inclusive.
Unit of Measurement: The time here is measured in seconds.
-
Other features:
If you like to redirect without seeing the preview page at the same time also keeping the Preview Before Redirect Plugin active, regardless of time (as defined or not defined by F21_PREVIEW_TIME
), we can use ?utm_redirect=auto&utm_preview=1
, to auto redirect without the preview page.
Expected Enhanced:
- Ability to toggle on or off this feature.
- Defining your own key-value pair.
Admin Area Add-On:
-
Enabling this plugin will add , at the admin area. Clicking on the same will redirect to the preview page, i.e.
sho.rt/link~
. -
If QR Module is enabled, the plugin will add at the admin area. Clicking on the same will redirect to the QR Page i.e.
sho.rt/link.qr
. - If the thumb module is enabled, the plugin will add at the admin area. Clicking on the same will redirect to the QR Page i.e.
sho.rt/link~
.
Installation:
Steps
- Download the code by either by
git clone
or by downloading asZIP
. - Extract and place it in
user/plugins
folder. - Go to the Administration Page -> Manage Plugins. Click to activate plugin.
Google PageSpeed Insights
We use Google PageSpeed Insights API to get you a thumbnail of the page you are requesting. This API works without an API_KEY
. However if you have too much traffic, you may exceed the quota. This will give you a 429 Quota exceeded for quota metric 'Queries' and limit 'Queries per minute
. To avoid such we request you acquire an API Key. Before you do so you may want to see the docs at https://developers.google.com/speed/docs/insights/v5/get-started. You can create an API Key from the docs too. If you are willing to use an existing API Key, you may do so. Please do not forget to enable PageSpeed Insights API. For security Google (and also myself) recommend you restrict the use of your API key to a subset of websites.
Caution: If you are limiting your keys to certain referrers only, please do not forget to add the exact domain (and path if any), to the list of exceptions as defined by the constant YOURLS_SITE
in users/config.php
.
If you are willing to use with an API Key, please use the following code to associate it correctly:
Note: Please avoid disclosing your API_KEY to anyone. If you see any unwanted traffic, consider regenerating your key.
Composer stuff:
If you want to you can always run the composer statement.
OR,
For more information about composer, visit Composer Documentation.
To know how to install composer.phar
, please see Installation Guidelines.
Word of caution!!
Introduction
I have been testing this on localhost
as well as https://stp.rf.gd
. I myself use the renowned Plugin Name: Sean's QR Code Short URLs with 404 If Not Found ☑️. However somehow if I go to the URL https://sho.rt/link.qr
it immediately shows me a HTTP 404 - Not Found Error
. I understood that the action loader_failed
was being fired after one of the following actions:
- [x] redirect_keyword_not_found
- [ ] infos_keyword_not_found
- [ ] redirect_no_keyword
- [ ] infos_no_keyword
Investigation & Faulty Code
On investigation I found these actions at https://yourls.org/hooklist.php. From there I searched each action being called. If you notice both redirect_keyword_not_found
and loader_failed
are being fired on the page yourls_loader.php
. On inspecting I found:
Please note -->
is not part of the code. It here denotes the faulty piece of code.
If you closely notice redirect_keyword_not_found
was fired befire loader_failed
. So link.qr
was being flagged by redirect_keyword_not_found
action (as it does not exist in the database) and hence a 404 Not Found
.
How to get rescued?
There are actually two ways.
- The simple way is to swap the faulty piece of code with each other, i.e.,
However it is not encouraged as if you change the code, you need to do the same for every update, and it is discouraged to directly modify the core.
- Find and comment each plugin(s) which use the action
redirect_keyword_not_found
such as the 404 Plugin by ozh.
Note: callback_function
can be action or filter present here in the hooklist.
Translating
This plugin already translated to English and Russian, simply uses whatever language YOURLS uses, as described here.
If you want to translate this plugin into your own language, this blog post from YOURLS describes how to do it. You can find the latest .pot file in the languages
folder of the plugin directory. Please follow the contributing guidelines below to add your translation to plugin.
Demo:
- For QR Preview: https://stp.rf.gd/f21.qr
- For Thumbnail Preview: https://stp.rf.gd/f21.i
- For Preview: https://stp.rf.gd/f21~
- For Pre-Redirect Preview: https://stp.rf.gd/f21
Testing:
This plugin has been tested on YOURLS 1.5 through 1.8.1
, both on localhost
and on a live server at https://stp.rf.gd
.
License:
The code is licensed under MIT License. A copy of the license should be included in every export of this plugin. However if the same has not been exported, the terms are as below.