{"id":17038643,"url":"https://github.com/wbotelhos/attachy","last_synced_at":"2025-04-12T13:52:48.778Z","repository":{"id":56842645,"uuid":"84888180","full_name":"wbotelhos/attachy","owner":"wbotelhos","description":":paperclip: Attachments handler for Rails via Cloudinary","archived":false,"fork":false,"pushed_at":"2018-04-23T02:10:08.000Z","size":109,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T08:37:11.760Z","etag":null,"topics":["activestorage","attachment","carrierwave","cloudinary","crop","dragonfly","image","paperclip","refinery","upload"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wbotelhos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-14T00:36:30.000Z","updated_at":"2017-12-12T21:48:08.000Z","dependencies_parsed_at":"2022-09-14T17:53:30.201Z","dependency_job_id":null,"html_url":"https://github.com/wbotelhos/attachy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fattachy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fattachy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fattachy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fattachy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wbotelhos","download_url":"https://codeload.github.com/wbotelhos/attachy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154998,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activestorage","attachment","carrierwave","cloudinary","crop","dragonfly","image","paperclip","refinery","upload"],"created_at":"2024-10-14T08:57:20.782Z","updated_at":"2025-04-12T13:52:48.749Z","avatar_url":"https://github.com/wbotelhos.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Attachy\n\n[![Build Status](https://travis-ci.org/wbotelhos/attachy.svg)](https://travis-ci.org/wbotelhos/attachy)\n[![Gem Version](https://badge.fury.io/rb/attachy.svg)](https://badge.fury.io/rb/attachy)\n\nAttachments handler for Rails via http://cloudinary.com\n\n## Description\n\nSend files from your browser directly to Cloudinary.\nAttachy will generate a `has_one` or `has_many` files (photos) to your model\nwith no need to change your model schema!\n\n## Install\n\nAdd the following code on your `Gemfile` and run `bundle install`:\n\n```ruby\ngem 'attachy'\n```\n\nSo, extracts the necessary files including a migrate that create a table used to keep your file metadata.\nYou can choose a [Default Image](#default-image) via params `version`, `public_id` and `format`.\n\n```bash\nrails g attachy:install\n```\n\nThen execute the migrations to create the `attachy_files` table.\n\n```bash\nrake db:migrate\n```\n\n## Usage\n\n### Model\n\nUpload a single image that will be overrided on each upload:\n\n```ruby\nclass User \u003c ApplicationRecord\n  has_attachment :avatar\nend\n```\n\nUpload a couple of images that will be added on each upload:\n\n```ruby\nclass User \u003c ApplicationRecord\n  has_attachments :photos\nend\n```\n\n### View\n\nExpose your Cloudinary credentials on your layout:\n\n```html\n\u003c%= cloudinary_js_config %\u003e\n```\n\nInto your form, add the upload field:\n\n```html\n\u003c%= f.attachy :avatar %\u003e\n```\n\n### Assets\n\nIncludes the `attachy.js` on your js manifest:\n\n```js\n//= require attachy\n```\n\nIncludes the `attachy.sass` on your css manifest:\n\n```js\n/*\n *= require attachy\n */\n```\n\n### \u003ca name=\"default-image\"\u003e\u003c/a\u003e Configurations\n\nOn your `attachy.yml` you can configure a default image to show when model has no file attached:\n\n```yml\ndefault:\n  image:\n    format: jpg\n    public_id: default\n    version: 42\n```\n\n## Transformations\n\nTo know more about transformations, check the [Cloudinary Doc](http://cloudinary.com/documentation/image_transformations).\n\n## Helpers\n\n### Attachy\n\n```html\n\u003c%= f.attachy :avatar,\n  t:      { width: 160, height: 160, crop: :fill },\n  tl:     { width: 800, height: 600, crop: :scale },\n  button: { html: { text: 'Upload' } }\n%\u003e\n```\n\n+ `t`: image transformations;\n+ `tl`: linked image transformations;\n+ `button.html`: button html attributes.\n\n```html\n\u003cdiv class=\"attachy\"\u003e\n  \u003cul class=\"attachy__content\"\u003e\n    \u003cli class=\"attachy__node\"\u003e\n      \u003ca class=\"attachy__link\" href=\"\"\u003e\n        \u003cimg src=\"\"\u003e\n      \u003c/a\u003e\n\n      \u003cspan class=\"attachy__remove\"\u003e×\u003c/span\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cdiv class=\"attachy__button\"\u003e\n    \u003cspan\u003e...\u003c/span\u003e\n\n    \u003cinput type=\"file\" class=\"attachy__fileupload\"\u003e\n\n    \u003cinput value=\"[]\" type=\"hidden\"\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n+ `attachy`: wrapper;\n+ `attachy__content`: the file content;\n+ `attachy__node`: each file of the content;\n+ `attachy__link`: the link of some file;\n+ `img`: the uploaded file;\n+ `attachy__remove`: button to remove the image;\n+ `attachy__button`: pseudo button to access the upload file button;\n+ `span`: the label of the button;\n+ `attachy__fileupload`: the upload file field;\n+ `hidden`: the field that keeps hidden the files metadata as JSON.\n\n## Link\n\nIt draws the link with the image inside:\n\n```html\n\u003c%= attachy_link :avatar, @object\n  t:    { width: 160, height: 160, crop: :fill },\n  tl:   { width: 800, height: 600, crop: :scale },\n  html: { class: :added_custom }\n%\u003e\n```\n\n+ `t`: image transformations;\n+ `tl`: linked image transformations;\n+ `html`: link html attributes.\n\n```html\n\u003ca class=\"attachy__link\" href=\"\"\u003e\n  \u003cimg src=\"\"\u003e\n\u003c/a\u003e\n```\n\n### Image\n\nIt draws the image:\n\n```html\n\u003c%= attachy_image :avatar, @object\n  t:    { width: 160, height: 160, crop: :fill },\n  html: { alt: :me }\n%\u003e\n```\n\n+ `t`: image transformations;\n+ `html`: link html attributes.\n\n```html\n\u003cimg src=\"https://res.cloudinary.com/account/image/upload/secret/version/hash.format\"\u003e\n```\n\n## Test\n\nBefore send pull request, check if specs is passing.\n\n```bash\nrspec spec\n```\n\n## Code Style\n\nCheck if the code style is good.\n\n```bash\nrubocop --debug --display-cop-names\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbotelhos%2Fattachy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwbotelhos%2Fattachy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbotelhos%2Fattachy/lists"}