PageSourceSearch

https://shrinerb.com/assets/js/68908ed9.5813a03d.js

js shrinerb.com collected 2026-10-03 23:13:20 UTC 22,604 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[5150],{3530(e,s,n){n.r(s),n.d(s,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"plugins/store_dimensions","title":"Store Dimensions","description":"The storedimensions plugin extracts dimensions of","source":"@site/../doc/plugins/store_dimensions.md","sourceDirName":"plugins","slug":"/plugins/store_dimensions","permalink":"/docs/plugins/store_dimensions","draft":false,"unlisted":false,"editUrl":"https://github.com/shrinerb/shrine/edit/master/doc/../doc/plugins/store_dimensions.md","tags":[],"version":"current","lastUpdatedBy":"Janko Marohni\u0107","lastUpdatedAt":1789922805000,"frontMatter":{"title":"Store Dimensions"},"sidebar":"plugins","previous":{"title":"Signature","permalink":"/docs/plugins/signature"},"next":{"title":"Type Predicates","permalink":"/docs/plugins/type_predicates"}}');var r=n(4848),t=n(8453);const a={title:"Store Dimensions"},i=void 0,o={},d=[{value:"Metadata",id:"metadata",level:2},{value:"Analyzers",id:"analyzers",level:2},{value:"API",id:"api",level:2},{value:"Disabling auto-extraction",id:"disabling-auto-extraction",level:3},{value:"Errors",id:"errors",level:2},{value:"Instrumentation",id:"instrumentation",level:2}];function c(e){const s={a:"a",code:"code",figure:"figure",h2:"h2",h3:"h3",p:"p",pre:"pre",span:"span",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s.p,{children:["The ",(0,r.jsx)(s.a,{href:"https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/store_dimensions.rb",children:(0,r.jsx)(s.code,{children:"store_dimensions"})})," plugin extracts dimensions of\nuploaded images and stores them into the metadata hash (by default it uses the\n",(0,r.jsx)(s.a,{href:"https://github.com/sdsykes/fastimage",children:"fastimage"})," gem)."]}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsx)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"})]})})})}),"\n",(0,r.jsx)(s.h2,{id:"metadata",children:"Metadata"}),"\n",(0,r.jsxs)(s.p,{children:['The dimensions are stored as "width" and "height" metadata values on the\nShrine::UploadedFile object. For convenience the plugin also adds ',(0,r.jsx)(s.code,{children:"#width"}),",\n",(0,r.jsx)(s.code,{children:"#height"})," and ",(0,r.jsx)(s.code,{children:"#dimensions"})," reader methods."]}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsxs)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:[(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"image = uploader."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"upload"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"(file)"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:" "}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"image."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"metadata"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"["}),(0,r.jsx)(s.span,{style:{color:"#DEE492"},children:'"'}),(0,r.jsx)(s.span,{style:{color:"#E7EE98"},children:"width"}),(0,r.jsx)(s.span,{style:{color:"#DEE492"},children:'"'}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"]  "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"#=> 300"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"image."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"metadata"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"["}),(0,r.jsx)(s.span,{style:{color:"#DEE492"},children:'"'}),(0,r.jsx)(s.span,{style:{color:"#E7EE98"},children:"height"}),(0,r.jsx)(s.span,{style:{color:"#DEE492"},children:'"'}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"] "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"#=> 500"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# or"})}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"image."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"width"}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"  #=>
1 300"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"image."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"height"}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:" #=> 500"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# or"})}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"image."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"dimensions"}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:" #=> [300, 500]"})]})]})})}),"\n",(0,r.jsx)(s.h2,{id:"analyzers",children:"Analyzers"}),"\n",(0,r.jsxs)(s.p,{children:["By default the ",(0,r.jsx)(s.a,{href:"https://github.com/sdsykes/fastimage",children:"fastimage"})," gem is used to extract dimensions. You can choose a\ndifferent built-in analyzer via the ",(0,r.jsx)(s.code,{children:":analyzer"})," option:"]}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsx)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"analyzer:"}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:" :mini_magick"})]})})})}),"\n",(0,r.jsx)(s.p,{children:"The following analyzers are supported:"}),"\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"Name"}),(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"Description"})]})}),(0,r.jsxs)(s.tbody,{children:[(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.code,{children:":fastimage"})}),(0,r.jsxs)(s.td,{style:{textAlign:"left"},children:["(Default). Uses the ",(0,r.jsx)(s.a,{href:"https://github.com/sdsykes/fastimage",children:"fastimage"})," gem to extract dimensions from any IO object."]})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.code,{children:":mini_magick"})}),(0,r.jsxs)(s.td,{style:{textAlign:"left"},children:["Uses the ",(0,r.jsx)(s.a,{href:"https://github.com/minimagick/minimagick",children:"mini_magick"})," gem to extract dimensions from File objects. If non-file IO object is given it will be temporarily downloaded to disk."]})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.code,{children:":ruby_vips"})}),(0,r.jsxs)(s.td,{style:{textAlign:"left"},children:["Uses the ",(0,r.jsx)(s.a,{href:"https://github.com/libvips/ruby-vips",children:"ruby-vips"})," gem to extract dimensions from File objects. If non-file IO object is given it will be temporarily downloaded to disk."]})]})]})]}),"\n",(0,r.jsxs)(s.p,{children:["You can also create your own custom dimensions analyzer, where you can reuse\nany of the built-in analyzers. The analyzer is a lambda that accepts an IO\nobject and returns width and height as a two-element array, or ",(0,r.jsx)(s.code,{children:"nil"})," if\ndimensions could not be extracted."]}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsxs)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:[(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"analyzer:"}),(0,r.jsx)(s.span,{style:{color:"#97E1F1"},children:" ->"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:" (io, analyzers) "}),(0,r.jsx)(s.span,{style:{color:"#F286C4"},children:"do"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"  dimensions   = analyzers["}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":fastimage"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"]."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"call"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"(io)   "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# try extracting dimensions with FastImage"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"  dimensions "}),(0,r.jsx)(s.span,{style:{color:"#F286C4"},children:"||="}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:" analyzers["}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":mini_magick"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"]."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"call"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"(io) "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# otherwise fall back to MiniMagick"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"  dimensions"})}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#F286C4"},children:"end"})})]})})}),"\n",(0,r.jsx)(s.h2,{id:"api",children:"API"}),"\n",(0,r.jsx)(s.p,{children:"You can use methods for extracting the dimensions directly:"}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsxs)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:[(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# or YourUploader.extract_dimensions(io)"})}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#97E1F1",fontStyle:"italic"},children:"Shrine"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"extract_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"(io) "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"#=> [300, 400] (calls the defined analyzer)"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# or just"})}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#97E1F1",fontStyle:"italic"},children:"Shrine"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"(io) "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"#=> [300, 400] (calls the defined analyzer)"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:" "}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# or YourUploader.dimensions_analyzers"})}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#97E1F1",fontStyle:"italic"},children:"Shrine"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"dimensions_analyzers"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"["}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":fastimage"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"]."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"call"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"(io) "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"#=> [300, 400] (calls a built-in analyzer)"})]})]})})}),"\n",(0,r.jsx)(s.h3,{id:"disabling-auto-extraction",children:"Disabling auto-extraction"}),"\n",(0,r.jsxs)(s.p,{children:["If you want to use the dimensions extraction methods but not automatically\nextract dimensions on upload, you can setup this plugin with the\n",(0,r.jsx)(s.code,{children:"auto_extraction: false"})," option."]}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsx)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"auto_extraction:"}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:" false"})]})})})}),"\n",(0,r.jsx)(s.h2,{id:"errors",children:"Errors"}),"\n",(0,r.jsx)(s.p,{children:"By default, any exceptions that the analyzer raises while extracting dimensions\nwill be caught and a warning will be printed out. This allows you to have the\nplugin loaded even for files that are not images."}),"\n",(0,r.jsx)(s.p,{children:"However, you can choose different strategies for handling these exceptions:"}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsxs)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:[(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"on_error:"}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:" :warn"}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"        # prints a warning (default)"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"on_error:"}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:" :fail"}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"        # raises the exception"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"on_error:"}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:" :ignore"}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"      # ignores exceptions"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"on_error:"}),(0,r.jsx)(s.span,{style:{color:"#97E1F1"},children:" ->"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:" (error) { "}),(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# custom handler"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"  # report the exception to your exception handler"})}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"}"})})]})})}),"\n",(0,r.jsx)(s.h2,{id:"instrumentation",children:"Instrumentation"}),"\n",(0,r.jsxs)(s.p,{children:["If the ",(0,r.jsx)(s.code,{children:"instrumentation"})," plugin has been loaded, the ",(0,r.jsx)(s.code,{children:"store_dimensions"})," plugin\nadds instrumentation around dimensions extraction."]}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsxs)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:[(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#7B7F8B"},children:"# instrumentation plugin needs to be loaded *before* store_dimensions"})}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":instrumentation"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"})]})]})})}),"\n",(0,r.jsxs)(s.p,{children:["Extracting metadata will send a ",(0,r.jsx)(s.code,{children:"image_dimensions.shrine"})," event with the\nfollowing payload:"]}),"\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"Key"}),(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"Description"})]})}),(0,r.jsxs)(s.tbody,{children:[(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.code,{children:":io"})}),(0,r.jsx)(s.td,{style:{textAlign:"left"},children:"The IO object"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.code,{children:":uploader"})}),(0,r.jsx)(s.td,{style:{textAlign:"left"},children:"The uploader class that sent the event"})]})]})]}),"\n",(0,r.jsx)(s.p,{children:"A default log subscriber is added as well which logs these events:"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{children:"Image Dimensions (108ms) \u2013 {:io=>File, :uploader=>Shrine}\n"})}),"\n",(0,r.jsx)(s.p,{children:"You can also use your own log subscriber:"}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsxs)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:[(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"log_subscriber:"}),(0,r.jsx)(s.span,{style:{color:"#97E1F1"},children:" ->"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:" (event) {"})]}),"\n",(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#97E1F1",fontStyle:"italic"},children:"  Shrine"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"logger"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"info"}),(0,r.jsx)(s.span,{style:{color:"#97E1F1",fontStyle:"italic"},children:" JSON"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"generate"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"("}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"name:"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:" event."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"name"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"duration:"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:" event."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"duration"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#F286C4"},children:"**"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"event."}),(0,r.jsx)(s.span,{style:{color:"#62E884"},children:"payload"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:")"})]}),"\n",(0,r.jsx)(s.span,{"data-line":"",children:(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"}"})})]})})}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)
1(s.code,{children:'{"name":"image_dimensions","duration":114,"io":"#<File:0x00007fc445371d90>","uploader":"Shrine"}\n'})}),"\n",(0,r.jsx)(s.p,{children:"Or disable logging altogether:"}),"\n",(0,r.jsx)(s.figure,{"data-rehype-pretty-code-figure":"",children:(0,r.jsx)(s.pre,{style:{backgroundColor:"#282A36",color:"#f6f6f4"},tabIndex:"0","data-language":"rb","data-theme":"dracula-soft",children:(0,r.jsx)(s.code,{"data-language":"rb","data-theme":"dracula-soft",style:{display:"grid"},children:(0,r.jsxs)(s.span,{"data-line":"",children:[(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:"plugin "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:":store_dimensions"}),(0,r.jsx)(s.span,{style:{color:"#F6F6F4"},children:", "}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:"log_subscriber:"}),(0,r.jsx)(s.span,{style:{color:"#BF9EEE"},children:" nil"})]})})})})]})}function h(e={}){const{wrapper:s}={...(0,t.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8453(e,s,n){n.d(s,{R:()=>a,x:()=>i});
1var l=n(6540);const r={},t=l.createContext(r);function a(e){const s=l.useContext(t);return l.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function i(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),l.createElement(t.Provider,{value:s},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.