Code Monkey home page Code Monkey logo

friendlythumbof's Introduction

#A friendlyThumbOf# ###Friendly url for phpThumbOf (MODx Revo)###

Generate friendly url for thumbnail image and use mod_rewrite to parse the url. This extra depend on phpThumbOf for rendering the thumbnail, but will do fine to generate url only. That's the main different with phpThumbOf. Using friendlyThumbOf, the thumbnail will be rendered later when there is a 'real' request to the server.


####Features####

  • Enable/disable friendly feature
  • Modify the url prefix (by default "image")
  • Enable/disable to append context to url, like http://mydomain.com/image/contextKey/anyMode/image.jpg
  • Add, modify and delete any mode as you wish from System Events. By default, there are 4 modes provided: default mw950, thumb w90&h120, medium w=300&h=400, and large w=900&h=1200
  • Sample mod_rewrite with 4 advanced scenarios can be found on doc core/components/friendlythumbof/doc/ht.access
  • TO DO: Plugin for cleaning up the cache

####Usage#### Call the snippet from resource or chunk:

[[friendlyThumbOf? &input=`media/logo.jpg` &mode=`thumb`]] 
/* will generate a url like http://mydomain.com/image/thumb/media/logo.jpg */
[[friendlyThumbOf? &input=`path/to/my/image.jpg` &mode=`anotherMode`]] 
/* will generate a url like http://mydomain.com/image/anotherMode/path/to/my/image.jpg */

For CMP, like gallery or image browser, the snippet also can be used to display the thumbail. For example:

<script type="text/javascript">
var thumbUrl = "[[friendlyThumbOf? &mode=`thumb` &base=`1`]]";
//will generate http://mydomain.com/image/thumb (without trailing slash)
var imgGallery = ['gallery/photo1.jpg','gallery/photo2.jpg'];
Ext.each(imgGallery, function(img){
  document.write('<img src="' + thumbUrl + '/' + img + '" />');
});
//...

Another example is using runSnippet to get the base thumbnail url:

<?php
$thumbUrl = $modx->runSnippet('friendlyThumbOf', array('mode'=>'anotherThumb', 'base'=>1));
/* will generate http://mydomain.com/image/anotherThumb (without trailing slash) */
$imgGallery = array('gallery/photo1.jpg','gallery/photo2.jpg');
foreach($imgGallery as $img) {
  echo '<img src="' . $thumbUrl . '/' . $img . '" />';
}
//...

friendlythumbof's People

Contributors

lokamaya avatar

Stargazers

John Peca avatar luk avatar Jan Tezner avatar Mark Hamstra avatar

Watchers

 avatar luk avatar James Cloos avatar Steffen Kaschke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.