Download the PHP package magyarandras/amp-converter without Composer
On this page you can find all versions of the php package magyarandras/amp-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package amp-converter
AMP ⚡ converter library
A library to convert HTML articles, blog posts or similar content to AMP (Accelerated Mobile Pages).
Note: This library is not intended to convert entire HTML documents if you want to convert an entire page you should use a more advanced library, for example: Lullabot/amp-library
Installation:
Currently supported elments:
- [x] amp-img
- [x] amp-img in amp-pan-zoom
- [x] amp-img with lightbox
- [x] amp-video
- [x] amp-audio
- [x] amp-iframe(A placeholder is automatically added to the iframes, so you can embed iframes even above the fold.)
- [x] amp-youtube
- [x] amp-facebook
- [x] amp-instagram
- [x] amp-twitter
- [x] amp-pinterest
- [x] amp-playbuzz
- [x] amp-gist(Github gist embed)
- [x] amp-vimeo
- [ ] amp-soundcloud(You can use amp-iframe instead)
- [x] amp-vk
- [x] amp-imgur
- [x] amp-dailymotion
- [x] amp-gfycat
Usage:
Simple example:
Make sure your HTML code doesn't contain tags or attributes invalid in HTML5 otherwise, the generated AMP will be invalid too.
The output:
You can specify which converters to use by loading them manually:
Images with unknown sizes
If you have images with unknown dimensions in your HTML code (you should avoid this situation if possible) and use relative URLs, you must pass the images' base URL to the constructor. You can also specify the time limit for obtaining the size of a single image (the default is 10 seconds). (Note: the time limit applies for every single image, not for the entire process)
Writing your own converters:
The library can't support everything out of the box, but you can extend it with your own converters(or you can replace existing ones if you need).
For example, consider the following: You use a jQuery countdown library in some of your articles/blog posts and you want to convert the following code to AMP.
You can create a custom converter class that implements the TagConverterInterface.
Using the custom converter: