1.0.0 • Published 10 years ago

imagey-filter v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
10 years ago

What is this?

imagey is an Angular filter that replaces links to images in text, with <img> tags, similar to how Angular's linky filter replaces links in text with <a> tags.

Basically, it turns this:

Check out this awesome google logo: https://www.google.com/images/srpr/logo11w.png

into this:

Check out this awesome google logo: <img src="https://www.google.com/images/srpr/logo11w.png">

How do I get this awesome code?

Use Bower, and, inside your project run bower install --save imagey-filter.

Okay, now what?

Add it to your Angular dependencies:

var myApp = angular.module('myApp', ['imagey'])

In a template

<div>
  <!-- To just turn image links into image tags -->
  {{ myContent | imagey }}

  <!-- To turn links into anchor tags, and image links into image tags -->
  {{ myContent | linky | imagey }}
</div>

In Javascript land

// Pull in the filter service
myApp.controller('fooCtrl', function($scope, $filter) {
  // Grab a reference to imagey
  var imagey = $filter('imagey')

  // And run it on some text
  $scope.withImages = imagey(plaintext)
})