All Projects → buck-ai → has_placeholder_image

buck-ai / has_placeholder_image

Licence: MIT license
A Ruby gem for generating string based placeholder images in Rails.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to has placeholder image

Ransack
Object-based searching.
Stars: ✭ 5,020 (+25000%)
Mutual labels:  ruby-gem, ruby-on-rails
Rorvswild
Ruby on Rails app monitoring: performances & exceptions insights for rails developers.
Stars: ✭ 159 (+695%)
Mutual labels:  ruby-gem, ruby-on-rails
Sidekiq Cron
Scheduler / Cron for Sidekiq jobs
Stars: ✭ 1,383 (+6815%)
Mutual labels:  ruby-gem, ruby-on-rails
Matestack Ui Core
Matestack enables you to create sophisticated, reactive UIs in pure Ruby, without touching JavaScript and HTML. You end up writing 50% less code while increasing productivity, maintainability and developer happiness.
Stars: ✭ 469 (+2245%)
Mutual labels:  ruby-gem, ruby-on-rails
wor-authentication
Gem to add authentication to your application using JWT, with expirable, renewable and customizable tokens!
Stars: ✭ 63 (+215%)
Mutual labels:  ruby-gem, ruby-on-rails
Motion
Reactive frontend UI components for Rails in pure Ruby
Stars: ✭ 498 (+2390%)
Mutual labels:  ruby-gem, ruby-on-rails
eight ball
Ruby gem for querying feature flags
Stars: ✭ 17 (-15%)
Mutual labels:  ruby-gem, ruby-on-rails
Loaf
Manages and displays breadcrumb trails in Rails app - lean & mean.
Stars: ✭ 360 (+1700%)
Mutual labels:  ruby-gem, ruby-on-rails
activerecord-crate-adapter
Ruby on Rails ActiveRecord adapter for CrateDB
Stars: ✭ 27 (+35%)
Mutual labels:  ruby-gem, ruby-on-rails
superglue
A productive library for Classic Rails, React and Redux
Stars: ✭ 106 (+430%)
Mutual labels:  ruby-gem, ruby-on-rails
Cloudinary gem
Cloudinary GEM for Ruby on Rails integration
Stars: ✭ 394 (+1870%)
Mutual labels:  ruby-gem, ruby-on-rails
request store-sidekiq
Provides an easy integration between RequestStore and Sidekiq
Stars: ✭ 32 (+60%)
Mutual labels:  ruby-gem, ruby-on-rails
Devise masquerade
Extension for devise, enable login as functionality. Add link to the masquerade_path(resource) and use it.
Stars: ✭ 380 (+1800%)
Mutual labels:  ruby-gem, ruby-on-rails
React on rails
Integration of React + Webpack + Rails + rails/webpacker including server-side rendering of React, enabling a better developer experience and faster client performance.
Stars: ✭ 4,815 (+23975%)
Mutual labels:  ruby-gem, ruby-on-rails
Pattern
A collection of lightweight, standardized, rails-oriented patterns.
Stars: ✭ 377 (+1785%)
Mutual labels:  ruby-gem, ruby-on-rails
Mailjet Gem
[API v3] Mailjet official Ruby GEM
Stars: ✭ 119 (+495%)
Mutual labels:  ruby-gem, ruby-on-rails
katapult
Kickstart Rails development!
Stars: ✭ 21 (+5%)
Mutual labels:  ruby-gem, ruby-on-rails
delayed-web
A rails engine that provides a simple web interface for exposing the Delayed::Job queue.
Stars: ✭ 71 (+255%)
Mutual labels:  ruby-gem, ruby-on-rails
Filestack Rails
Official Ruby on Rails plugin for Filestack File Picker that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
Stars: ✭ 220 (+1000%)
Mutual labels:  ruby-gem, ruby-on-rails
activerecord-setops
Union, Intersect, and Difference set operations for ActiveRecord (also, SQL's UnionAll).
Stars: ✭ 21 (+5%)
Mutual labels:  ruby-gem, ruby-on-rails

HasPlaceholderImage

Test Maintainability Test Coverage Gem Version

Has Placeholder Image is a Ruby on Rails plugin that allows developers to generate placeholder images for models that has ActiveStorage fields.

Installation

Add this line to your application's Gemfile:

gem 'has_placeholder_image'

And then execute:

$ bundle

Or install it yourself as:

$ gem install has_placeholder_image

after generate configuration file with this command;

rails g has_placeholder_image:install

Usage

Insert this method to your model which will have placeholder images:

has_placeholder_image

You can customize default configuration with config/initializers/has_placeholder_image.rb or you can customize placeholder image generation on model basis by adding custom attributes to placeholder callback.

For example;

has_placeholder_image source: :title, 
                      target: :logo, 
                      background_color: '#335eea'

Configuration

The default configuration lies in config/initializers/has_placeholder_image.rb and can be customized according to your liking.

HasPlaceholderImage.setup do |config|
  config.background_color = '#000000'
  config.font_color = '#FFFFFF'
  config.font_size = 200
  config.transformer = 'two_word_first_letter_upcase'
  config.source = 'name'
  config.target = 'photo'
  config.output_path = 'tmp/placeholders'
  config.height = 300
  config.width = 300
end
Key Description
background_color For image background color.
font_color For text color.
font_size For font size.
transformer How to generate your image title. This time only have 'two_word_first_letter_upcase' method.
source Placeholder image text generate with this field.
target Your active storage attribute on your model.
output_path Where to store generated images path.
height Generated image height.
width Generated image width.

Example

app/models/company.rb

# frozen_string_literal: true

class Company < ApplicationRecord
  has_one_attached :logo
  has_placeholder_image source: :title, target: :logo,
                        background_color: '#335eea',
			            font_size: 200

  validates :title, presence: true
end

Output

Contributing

See the contributing guide.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].