Closed (fixed)
Project:
Styles
Version:
7.x-2.x-dev
Component:
User interface
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Dec 2010 at 19:38 UTC
Updated:
1 Jul 2011 at 20:31 UTC
Jump to comment: Most recent file
Comments
Comment #1
Scott J commentedI am a little confused by your terminology.
Did you add a field of type "Image" known as an imagefield, or did you add a field of type "Multimedia asset" ?
And imagecache is now called "Image style".
Comment #2
Scott J commentedIf you only need to display images, I would suggest using a field of type "Image", as it will be much simpler to use your desired Image Style preset, as it can be selected directly in Views.
But if you really need to use multimedia asset field, to be able to display videos or other file types, I think it will involve three steps:
Comment #3
jdblank commentedThanks Scott. We were using a media field so we could reuse the images elsewhere as needed through WYSIWYG etc. But if that is not the right approach we can just switch them out to use standard Image.
Comment #4
Scott J commentedYou'll find that images that are uploaded to imagefields are automatically added to the media library, so will be available in the wysiwyg inline browser button thingimy either way.
Now that image support is finally part of Drupal core, I'll be using it wherever possible, and saving multimedia till it's absolutely necessary, especially with Media module being so new.
Comment #5
JacobSingh commentedYeah, this is something we've been really concerned with, but don't know how to provide a better user experience yet. Styles is really useful for the abstraction it provides. Because of styles, we can have multimedia galleries and also have flickr images and local images in the same field.
But configuring it impossible for a novice.
My desire is to be able to replace the imagefield widget with the media browser. So that people who want multi-media asset fields can do that, but people who want the simplicity of image or file fields can use the media browser.
Does this sound like a good way to go about it?
Comment #6
Scott J commentedAbsolutely!
Comment #7
effulgentsia commented#5 is well worth exploring, but I think this issue, as stated, belongs in the Styles queue, so moving it there.
Comment #8
nedjo[Edited to remove an irrelevant section.]
A good first step would adding some basic documentation to the page at http://drupal.org/node/703336. The steps in #2 are maybe a start, but I was unable to get this working.
Here's what I've tried.
General setup
Creating a custom style
(Trying to follow the steps in #2, above)
Result
Comment #9
rvilar+1 for me. It's impossible to select the new image style preset
Comment #10
derekahmedzai commentedSame problem here. Using drupal 7.0 and styles-7.x-2.0-alpha5
Comment #11
peronas commented+1 for me as well
Comment #12
robertgarrigos commentedI've been looking into this a bit and found I couple of things:
1. there is a new function (function styles_default_presets) with a bunch of code (near line 334 of styles.module) which would have to get user defined presets. This is the function used to build the select form item when configuring the file style. The first problem is that drupal never gets to that bunch of code because of the cache. The only way to get drupal execute that code was by changing to 'true' the default value of the boolean argument 'reset' of this function, so it resets the cache.
2. once drupal executes that code, you will see that it doesn't return any user defined preset, stored in the table 'styles_preset_instances', because it is empty, even I've created a new file style. why is that?
I whish I could be of more help.
Comment #13
peronas commentedI've been digging through this for a chunk of time now was hoping someone might be able to clarify a few things for me in hopes I'll understand this.
To me it seems that there is a disconnect from file styles directly connecting to image styles that have been defined. Based on what I understood when looking over 'styles_default_presets', which loads the options for the presets drop down, and how the presets are defined in 'file_styles_styles_default_presets', it seems that file styles connect to presets that then connect to the image styles.
To illustrate this when creating a new file style you will see 'unlinked_thumbnail' in the preset select. This preset is defined in 'file_styles_styles_default_presets' as follows:
From this it appears the preset specifies what image style to use so the file style is never directly associated with the image style.
This is where I feel there is a disconnect in what the expected interaction is between file styles and image styles. Using the UI you can create a new image style and a new file style but there doesn't appear to be a way to create the necessary preset go-between that would connect the two, thus we are unable to associate the newly created image style with a file style.
I was hoping some one could clarify for me how file styles are intended to relate to image styles, and if the intended structure is (file style)-->(preset)-->(image style) then how one would go about creating the necessary preset to be able to use a newly created image style with a file style.
Thanks!
Comment #14
R.Muilwijk commentedsubscr
Comment #15
hansfn commentedsubscribe
Comment #16
sw3b commentedSubscribe
Comment #17
bennash commentedsubscribe
Comment #18
ChrisFlink commentedsubscribe
Comment #19
camdarley commentedSubscribe! This module would be wonderful with functionality like that
Comment #20
Ganganation commentedSubscribe!
I thought it was supposed to work like the description.
Comment #21
tony-l commentedI'm also having a problem with the relationship between File Styles and Image Styles.
I don't have an answer but would like to contribute the following to this thread.
I installed Media Gallery and found that when I go to set the Media Type format in Config > Media > Media types > Image > Manage display > Gallery Thumbnail, etc. the File, Format drop-down menu is missing some styles.
The menu (see My_Menu.jpg) includes my File Styles (see My_FileStyles.jpg), but doesn't include my Image Styles (see My_ImageStyles.jpg). A similarity can be seen between the contents of File and Image Styles (square_thumbnail, thumbnail, medium and large) but are they the same and why are the gallery styles and the style I created (width240px) missing from the drop down menu? I think some link is missing.
On DrupalGardens in Config > Media, File Types aren't listed but Image Files are (see DG_ImageStyles), and the equivalent dropdown menu I refer to above lists 8 File Styles (see DG_Menu.jpg).
Everything works on Drupal Gardens, both on their server and when exported and hosted elsewhere, but it's not the same with a clean D7 build. DG have presumably done something to correct the missing link.
I hope that someone with an understanding of these things can shed some light.
Tony
Comment #22
c-c-m commentedI'm having the same issues/frustrations than you. I copy what I wrote in another issue with no reply at all, hoping it may be of some use:
I have made some improvements on this, but haven't found a solution yet. We have several related options that can be confusing, correct me if I'm wrong:
That's what I want to achieve
Create a media field that will display whatever media it has (image, video or youtube video) width a specific with of 640px
That's what I did:
That's what I got
Although images are displayed as expected, youtube videos have different widths
What am I doing wrong?
Comment #23
roske commentedI'm having this same issue as well. I'm running 7.0-2.x-dev. I made a large_cropped image style and can't find it in presets drop-down.
Comment #24
oxyc commentedSubscribing
Comment #25
oxyc commentedAlright I played around with it a little bit (bare in mind I'm quite new to development) and got this hook just to get it working:
I wanted to do it with
HOOK_styles_default_presets_alter()and I got the presets to show up but they would reset to the default preset when saved. Maybe someone with more experience knows why...This is quite the ugly hack and should probably be done properly together with
hook_styles_styles()in styles.api.phpMaybe a maintainer could point us in the right direction?
Comment #26
oxyc commentedI added some code to allow merging of styles, presets and default preset in the
styles_default_presets()hook. It currently allows merging containers and file types so in my opinion it only makes sense to allow merging of everything.The patch I attached would solve this issue (not in the UI alone) as you could create a simple hook like:
And then you can add presets and styles easily to containers. I thought this sounded logical and required minimum code change so maybe this was the original intent?
Comment #27
oxyc commentedOh, didn't really think it through.. with this patch it's impossible to completely override the styles/presets...
I'd love to help out with this module so if I can get some information on how it's intended to extend styles I'll give it my best shot.
Comment #28
oxyc commentedI apologize for my sad attempts at fixing this issue hehe... I think I found the actual problem now, I dont know if my fix is correct but this will probably help others understanding the problem.
The issue was that the user-defined presets would reset to the styles
default presetas thestyles_default_presets_alterhook was run afterwards and therefore the user-defined presets didn't yet exist. My patch might not be the best as it doesnt run the alter hooks last. I also saw thatstyles_instanceis looking for aselected presetthat currently never gets set, maybe this should be used instead.I'm guessing this is same for all alter hooks implemented in the module, I would ask someone with more experience to have a look at this.
Together with the above patch I can now implement an alter hook that adds the image styles (I'm kind of wondering if this is meant to be built into the Styles module or if the module is supposed to be this abstract).
Comment #29
3rdLOF commentedsubscribing.
Comment #30
3rdLOF commentedThat worked out like butter for me.
And for those who - like me- are still in diapers about using custom hooks, are too lazy and/or in a hurry, I suggest using the MyHook module: http://drupal.org/project/myhook
(This presumes you created a custom Image Style already)
1 - Apply oxyc's patches #26 and #28
2- Download install MyHook. Activate.
3 - Got to MyHook Admin UI at /admin/config/development/myhook >> Copy oxyc's code from #28 in the Content of myhook.module making sure you rename the function as myhook_styles_default_presets_alter Leave the rest alone (not because you should, simply because that is all I did and it worked)
4- Clear cache
5 - Now visit the File Style at /media/file-styles/edit/ and the custom Image Style should be listed in the drop down menu of the vertical tabs
Boom, there it is!!
Thanks again oxyc
Comment #31
oxyc commentedThis really needs to be reviewed by aaron first, I'm not quite sure how he intended it or if this issue is even a bug.
These patches are really quick fixes and will never get commited. I'm still learning Drupal so I'm making a lot of mistakes.
- What the first patch does is allow you to hook in only your own presets on styles created by other modules. Uses
HOOK_styles_default_presets()- The second patch "fixes" an issue where you can't alter already defined styles to include your presets. This way you you can use
HOOK_styles_default_presets_alter()Both of them makes image styles available but in different ways so you only need one.
Another way of adding the styles, without using any patches (maybe the best option for now) is to use this hook described last on this page.
Comment #32
3rdLOF commentedOh no do not worry, it is clear that this is only at the experimental level....No issues with that, but I simply posted that should anyone without that much experience with hooks could play with it,
Comment #33
oxyc commentedHope so hehe. Thanks for the post, will definitely make it easier for people.
I'm just a tad worried since I couldn't stop committing (prematurely maybe) once I did my first - got hooked I guess. Hopefully it's more helpful than counter productive for aaron.
Comment #34
sol roth commentedIt was mission critical that I have this working for a new site build, the patches and module code work perfectly for images. I also need custom thumbnail imagecache setting for the other types of media (video specifically). Would a modification of the module (#28) work for setting custom sized video thumbnails?
Comment #35
oxyc commentedHey,
I haven't used any of the other containers but I guess it should work if they are thumbnail image styles.
I think it's alot wiser not using the patch provided in #28 as it will never get commited, instead you can use the hook http://drupal.org/node/1092444 and wait for a proper Styles patch that makes this possible.
A modified version to integrate the presets for video, audio and default would look like this (haven't tested):
If for some reason you have to use the patch from #28 just replace:
with
Comment #36
sol roth commentedTHANKS!!!! It works great, the hook and I reversed the patch from #28. I need to add support for "YouTube", it doesn't inherit the Video type settings (has it's own file style you can choose in views etc), so you can't choose the custom styles, but everything else is working well. I was previously using an older release for youtube media and am now testing the dev version.
Comment #37
oxyc commentedIf it's just for using images again then all you should have to change is
array('image', 'video', 'audio', 'default')intoarray('image', 'video', 'audio', 'default', 'media_youtube')Comment #38
Mac Ryan commentedSubscribe
Comment #39
anthonyR commentedsubscribe
Comment #40
RobW commentedOxyc, thanks for giving us a stop-gap implementation of image styles->file styles. It's some pretty essential functionality if you need media module functionality in any way on a site.
Using the hook in http://drupal.org/node/1092444 I'm not getting the image style merge, and Drupal is throwing the errors:
Line 14 of custom.module is
$file_styles['containers']['image']['presets'] = array_merge($image_presets, $file_styles['containers']['image']['presets']);Any thoughts?
Comment #41
RobW commentedCan anyone tell me where valid options for the $field_type param string come from? The module gives the example filefield and nodereference, Oxyc's solution which I'm trying to implement gives 'file', although I think there have been code changes that make that invalid as I'm getting no array from calling styles_default_presets('file').
I've been going at this from a couple different directions, playing with Oxyc's hook and trying to append a hard coded style to $file_styles like so:
but no luck, because, as I mentioned, there is no array returned from styles_default_presets('file'). If anyone can help me get this working I'll be happy to write/revise documentation to cover it for others.
Comment #42
oxyc commentedSorry for not responding earlier, currently I don't have a computer to test the changes made in the media module so this post is just some thoughts.
- As styles module hasn't been updated the hook should work, as it only uses Styles module functions and according to effulgentias post the updates in media should be a seamless upgrade.
- file is the field type used by the file styles module as well as Media modules file entity (I assume).
@RobW are you using Drupal 6? Looking at your hook I see imagecache used, this has been changed to image_style in D7 and unfortunately I haven't done any tests on D6. Also the container used for images is image and not imagefield.
Assuming you are using D7, have cleared your cache and
styles_default_presets('file')still doesn't return anything it seems like file_styles hook hasn't been run yet. I don't really know how module hooks get prioritized in Drupal but I guess this could be the problem.Here you can see how File Styles attach the presets. What my hook does is basically copying what
file_styles_styles_default_preset()returns into the$file_stylesvariable and merging it with presets generated from image_styles.Hope this can help you with looking into the issue. I don't know when I'll get back to my laptop to test this myself. Sorry if I confused you further, it's been some time since I've been around the code so I might have missed something.
Comment #43
RobW commentedOxyc,
Thanks for the reply. I'm heading out for the night, and I'm going to look at your suggestions closer in the morning. But a couple things:
I'm using Drupal 7 - the code in the example is copied almost verbatim from how-to comments in the Styles module. I thought it was odd as well, but assumed it was a machine name/ui name difference. Now I'm thinking it's leftover docs from the 6.x branch.
I was thinking it might have something to do with module priority too, but I know even less than you. Thanks for the starting points, I'll root around some more in this tomorrow and see what I come up with. It might all be moot in a couple of weeks as it seems like Styles won't be a dependency for Media in the future (#1086958: Switch from Media Entity to File Entity).
Comment #44
RobW commentedLooks like I'm following you around the issue queue. I noticed your post in #1126170: How Can I Use Custom Image Styles as Formatters?: is your hook meant to work with Media only after the huge file-entity patch? I may have been using a dev version from before that was committed.
[edit for clarity]
Comment #45
rootworkSubscribe
Comment #46
meishme commentedSubscribe
Comment #47
shinz83 commentedSub. I would also like to have Media include the Image Styles hook. Is this going to be in future releases? I'd rather not have to patch up the code right now.
Until then.. it's the Image Field for this novice.
Comment #48
wjaspers commentedSub
Comment #49
benanderson commentedsubscribe
Comment #50
nedjoThe UI issue is fully answered in #1126170-19: How Can I Use Custom Image Styles as Formatters?.
To provide a code-based image style, create a corresponding file style, and link the two, here is working code using the available hooks:
Marking this issue fixed as fixes are in place for both UI and code.