Coder Social home page Coder Social logo

virtua-sa / media_entity_icon Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 40 KB

Media entity icon provides SVG sprites and SVG icons as assets via the Media entity module and can automate icons and thumbnails creation.

License: GNU General Public License v2.0

CSS 0.97% PHP 98.55% HTML 0.49%

media_entity_icon's Introduction

About Media entity

Media entity provides a 'base' entity for a media element. This is a very basic entity which can reference to all kinds of media-objects (local files, YouTube videos, tweets, CDN-files, ...). This entity only provides a relation between Drupal (because it is an entity) and the resource. You can reference to this entity within any other Drupal entity.

About Media entity icon

This module provides SVG sprites/icons integration for Media entity (i.e. media type provider plugin).

Features:

  • SVG sprite and SVG icon media types
  • Supports both local and CDN sprite sources
  • Sprite administration page to see the available icons, the ones created and the obsolete ones (in case of a source change)
  • Option to automatically create icons on a new sprite creation
  • Option to automatically create missing icons on a sprite update
  • Icon thumbnail can be generated as a PNG via SVG2PNG
  • Theme to render SVG icons based on an inline call with a use tag

Configuration

Thumbnail width and SVG2PNG can be configured on the settings page: /admin/config/media/media_entity_icon
This requires the "administer site configuration" permission.

Automated creation of icons at SVG creation/update can be set on the SVG sprite bundle: /admin/structure/media/manage/svg_sprite
This requires the "administer media bundles" permission.

Related icons can be managed as a dedicated tab on the SVG media entity: /media/{media}/related_icons
Accessing to the page requires the "access related icons" permission.
Creating icons automatically or via the related icon page requires either "create media" or "autocreate icon" permission.

Working with SVG sprites

An icon must be coupled with a sprite to work, the SVG sprite entity represents the source file and the SVG icon a pointer to a symbol within it.

The SVG parser expect a wrapping <svg>, in which each icon is defined by a <symbol> with an "id" attribute and some size attributes (either "viewbox" or "width" and "height).

For example, a very simple SVG sprite with a square, a disc and a triangle:

<svg xmlns="http://www.w3.org/2000/svg">
  <symbol id="square" viewBox="0 0 30 30">
    <rect x="0" y="0" width="30" height="30"/>
  </symbol>
  <symbol id="disc" viewBox="0 0 30 30">
    <circle cx="15" cy="15" r="15"/>
  </symbol>
  <symbol id="triangle" viewBox="0 0 30 30">
    <polygon points="0 30,30 30,15 0"/>
  </symbol>
</svg>

Recommanded

For thumbnail generation, we advise you to install svg2png (requires nodejs):

npm install -g svg2png

Project

Project page: https://www.drupal.org/project/media_entity_icon

Maintainers:

media_entity_icon's People

Watchers

Neustradamus avatar James Cloos avatar Jérémy WALTHER 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.