Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am building a new website on Umbraco 7.12.3 which will be used to showcase a collection of photos. Each photo will have its own page.
I would prefer not to use the media section for these photos as they don't need to be reused elsewhere on the site. Therefore, I have used a file upload field on the doctype instead of using a media picker.
However, in my razor template, I need access to the width and height of the image. This would usually be done with the umbracoWidth and umbracoHeight properties on a media item but since I am using a file upload property and not a media picker, these values are not available.
Is there any way to get the width and height of an image uploaded via the file upload property?
Fairly sure there is no data stored other than the location of the image if you use an upload field because it does not know what you are uploading (pdf, image, word doc, etc.).
Using a media picker in Umbraco 7 you can still upload the file on the fly (just like an upload field) but have a lot more scope to work with the image dimensions once the image is added. You can also tailor that specific media picker with any constraints if required (e.g. only allow one item selected/uploaded from one specific section).
Other than the images not being re-used what are your other reasons for not using the media section for media items?
There will likely be a few thousand images uploaded so I thought it would be easier to keep the images organised if they were uploaded directly to the page node. Then the media section would just be used for images that will be reused e.g. banner images.
It's not too hard for the user to upload images via the media picker and this is the method I would use normally. However, since each image needs its own page there would be a need to organise both the page nodes and image files separately which is what I was hoping to avoid.
I have read a post that suggested that in older versions of Umbraco (4 I think) it was possible to add a file upload to a page node as well as the umbracoWidth and umbracoHeight properties. These properties would then be updated when an image was uploaded, just like it currently does on a media item. I have tried this but it doesn't work sadly. Is there any way to get this functionality in v7?
Here is the code I ended up using to solve the problem, just in case anyone else has a similar requirement. :)
Code goes in the App_Code directory. I ended up using "image cropper" for the field property.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted