User:Codehydro/Auto CSS image crop: Difference between revisions

Content deleted Content added
m small note
max in bSize
 
(9 intermediate revisions by 2 users not shown)
Line 4:
 
== Installation ==
To implement this, add this to your [[Special:MyPage/common.js|common.js]] page (or any skin works fine): <code>importScript('User:Codehydro/Auto CSS image crop/script.js');</code>
 
<code>importScript('User:Codehydro/Auto CSS image crop/script.js');</code>
== Usage ==
 
In addition to activating this page, new button "Open Auto CSS image crop" will be available on the far right of the editing toolbar to provide quick access to this tool on other pages. If you do not want this button, simply add <code>DisableAutoCropEverywhere = true;</code> before the the importScript line. The tool will still automatically load on this page.
Enter the file name (e.g. Dew on grass Luc Viatour.jpg) and a bSize value. Once both of these are entered press tab or click outside of the form and a preview of your image will automatically appear. Adjust cWidth/cHeight in the form to change how the image is cropped. Change oTop/oLeft or use the scroll bars to position your image. You may change the bSize and the script will resize the image while preserving the crop position. The source code will automatically be generated below the input.
 
Alternatively, you may simply copy the above line (or the contents of [[User:Codehydro/Auto CSS image crop/script.js|script.js]] and [[User:Codehydro/Auto CSS image crop/functions.js|functions.js]]) and execute it either in your URL bar, in the JavaScript console, or via a [[bookmarklet]] (just Google it).
 
== Usage ==
=== Quick Start ===
Enter the file''Image'' namefile (e.g. Dew on grass Luc Viatour.jpg) and a ''bSize'' value. Once both of these are entered press tab or click outside of the form and a preview of your image will automatically appear. Adjust cWidth/cHeight in the form to change how the image is cropped. Change oTop/oLeft or use the scroll bars to position your image. You may change the bSize and the script will resize the image while preserving the crop position. The source code will automatically be generated below the input.
 
You can also populate values by pasting existing {{t|CSS image crop}} templates into the ''Import'' field (click out to finalize). If the pasted template contains parameters not covered this tool (e.g. Location or Description), the generator will attempt to preserve them in the output code.
 
=== Check ===
Line 19 ⟶ 27:
|oLeft = 60
}}
To make sure the generator works properly on your browser, try enteringcopy the following values into the formimport field and see if it looks just like the image pictured above:
<pre>{{CSS image crop
|Image = Dew on grass Luc Viatour.jpg
Line 28 ⟶ 36:
|oLeft = 60
}}</pre>
 
=== Advanced ===
* Press the up/down arrow keys to increase/decrease the field's value by 1% of bSize when in the cWidth, cHeight, oTop, and oLeft fields.
* Click opposite corners of the area you wish to frame and a guide lines will appear. Finalize crop using the "Crop to clicked" button.
* Undo clicks by holding "shift" and click on the image.
* Set cWidth or cHeight field to ">###" and your current crop will be scaled to such that cWidth or cHeight will be "###". Alternatively, you can set the field value to "1>3" or "2>1" and all fields will multiplied by a factor of 3 or divided by 2, respectively.
* Type "max" anywhere in the bSize field and the native width of the image file (max bSize allowed) will be automatically loaded upon clicking out of the field.