homepage Welcome to WebmasterWorld Guest from 54.197.147.90
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Content Management
Forum Library, Charter, Moderators: ergophobe

Content Management Forum

    
Drupal7, Images driving me nuts (teaser and image styles)
I will appreciate some help with this, I already did my homework
explorador




msg:4463128
 9:04 pm on Jun 8, 2012 (gmt 0)

Hi fellow webmasters I will need your help, I believe I reached my limit here :(

I have two main issues here:
1. Stopping Drupal from duplicating (resampling and recreating images)
2. Importing my image thumbnails into Drupal7 (each page has a preview image that appears on the listings)

First #1. Every page has a thumbnail, but every time I upload an image, Drupal creates diff versions (thumbnail, medium, large). I can't find a way to disable this (can't delete image styles on D7). I already overrided the settings and removed the "resampling", I also tried deleting the image styles, even configured the fields to use the original image but after a while, D7 starts creating dirs and subdirs with resampled versions. I'm working with fully optimized images on a gazillion images website so I can't afford this. My D7 is already configured to use one directory... please help :(

- - - - - - - -

Now #2, the trickiest.

I'm migrating gazillion pages to Drupal from a custom CMS, had lots of problems as FEEDs stopped working and behaves erratically after 7.12 to 7.14, SO, I built custom routines to export and import my data into the database (nodes, taxonomy, url alias, etc), [that is working fine, awesome].

BUT! every page (node) has not only a title but also a preview image, a thumbnail. I studied the database structure and the directory structure so I found a way to mimic the behaviour and data structure, created my data and imported it... nothing. The files are there but they just don't show.

After many tries I managed to make D7 recognize the images, they appear on edition, but not on full content or teasers. I just don't get it, the data is there but the html tries to display the images but using width=0 and height=0... I already went into the database and imported those values but D7 keeps printing html with width and height = 0, so, no visible image.

I also deleted the cache everywhere... nothing, even inside the database. Also, after a while the site begins using alternate versions of the images when there has been no change...


I could start with no thumbnails (keeping my old data without thumbnails but can't afford D7 creating random resamples images for the new content... as for inline image insertion I created a modified version of Nicedit, so that's out of the database structure, it will be inserted on the body... not on any other field, D7 won't even "see" those images....


Help please :)

 

ergophobe




msg:4463175
 11:18 pm on Jun 8, 2012 (gmt 0)

Okay, first things first: I feel your pain. Just did a similar thing and getting the images into Drupal was just nightmarish. I only had about 500, and after a few tries at creating an import script, I just gave up and literally hand-imported into Drupal (meaning I added the images through the Drupal interface).

This is extremely painful, except that I don't have *that* many pages - probably average 10 images per page, and with a multi-upload plugin, it wasn't that bad in the end.

All that to say, I'm not sure I can really answer your questions, because I gave up and just did it the Drupal way.

Stopping Drupal from duplicating (resampling and recreating images)


The derivative images should not get created until they are actually viewed - so if your theme isn't calling for them, the images should not get resized and resampled. This includes the admin side, though, so if you have thumbnails appearing on the admin side, the thumbnails will get generated. You can't stop that without some serious theming on the admin side and that will be painful.

Is it a storage issue? You can simply choose not to use the resampled versions and theme it to use your custom thumbnail.

>>The files are there but they just don't show.

You have them in the file_managed and the file_usage tables and you also have a field_data_#*$!xx and field_revision_#*$!xx for the image field and have those all linked to the node? That's pretty complicated to get right.

>>width=0 and height=0

Do you have the dims set in field_data_#*$!xx and field_revision_#*$!xx ?

As a general observation, you might need to do something like create a "field collection" where you upload the thumbnail and the main image separately and link them together at the theme level.

I set up mine so I could have a "teaser" image that is custom if I have one, but otherwise takes the first image from the gallery. Similar (though much easier) problem. It's at the theme level that I decide which image to use for the article teaser.

explorador




msg:4463967
 3:49 pm on Jun 11, 2012 (gmt 0)

Thanks Ergo. It helps to know that I'm not alone and that it is not an easy problem to solve. Painful! to import 500 items like that!

I checked the theme and tried others, the extra image styles still are there. I configured everything to STOP using thumbnails but it happens anyway (but not 5 of 5) it just... "sometimes", doesn't make sense to me. Storage is not still the problem, but managing several copies of the same (unnecesary) is not what I look forward into, specially due to seldom migrations (it isn't one of my sites, it belongs to the company I work for so there are often silly decitions being made).

>>The files are there but they just don't show.

You have them in the file_managed and the file_usage tables and you also have a field_data_#*$!xx and field_revision_#*$!xx for the image field and have those all linked to the node? That's pretty complicated to get right.

YEP. I finally got it right, then "sometimes" the right images are called but they don't show.... still... they appear on 0,0 (width and height)

Do you have the dims set in field_data_#*$!xx and field_revision_#*$!xx ?

Yep, no luck...


As a general observation, you might need to do something like create a "field collection" where you upload the thumbnail and the main image separately and link them together at the theme level.

Thanks, I will try that.


On the other side I'm trying something, perhaps this could be useful for you...
Yep, I'm still working on it...
1. I removed the "image" from the content style.
2. Added "upload file" with jpg allowed
3. Added FULL HTML long text field
4. Added custom JS include to enable my custom NICEDIT as editor... that's working fine already.

Well, I will add some JS functionality SO, when I upload an image file, the JS (via interval) will set the longtextfield to IMG SRC value of the file, along with the html text <img src=etc... AND CSS style "class='xx'". This is working already (JS pending).

So I modified the display for full and teaser, it works. The image is never resamples because it is treated as a non image. The interval will also fix the "null value" if no image is uploaded or if the current image is deleted. Yep, it is working BUT I'm yet to experiment further with teasers and VIEWS (because this site will require custom views to construct the front page....

I'm totally AGAINST modifying the modules because every update will break the system but I managed to construct everything around a js include... the JS builds everything else on the page.

I'll keep trying.

ergophobe




msg:4464039
 5:27 pm on Jun 11, 2012 (gmt 0)

I'm totally AGAINST modifying the modules


Agreed. Sometimes it can't be helped, but in that case I create a new module. Say my site is called My Site, I'll use an MS prefix as in "image_MS" for a module name. I have only done this once or twice and only with not regularly maintained third-party modules. I would not do it with anything in core.

Most often, I can use the hook system and get in there and modify forms or whatever. Most sites I build end up with a module called "tweaks_XX" (i.e. tweaks_MS in the My Site case).

I then use this module whenever I need to just hook in and make a small change in behavior. This keeps everything working through upgrades as long as the API doesn't change (which should be a major version change only, and even then perhaps not).

I checked the theme


And you're using only one theme for both public and admin?

explorador




msg:4464153
 9:59 pm on Jun 11, 2012 (gmt 0)

And you're using only one theme for both public and admin?

I'm confused. My install has:

1. Garland
2. Stark
3. Seven

The thing is, there is a theme for display and the theme for administrative work... Well, the multple images (resampled) appeared regarless of the theme I was using... I just can't avoid those "image styles"...

I have some work to do so still can't play with this experiment, but I will continue trying.

explorador




msg:4464623
 11:21 pm on Jun 12, 2012 (gmt 0)

Finally made it!

I'm only using one field for image preview, as mentioned before, "original image", no thumbnail but it was a pain to import everything. Well, I inserted the width and height (as before) but before calling the page I ended importing everything into the database, THEN emptied the cache and cache field on the database manually, now it works, every image has been imported just fine!

I did the same before and just calling any page one time ruined everything and couldn't find the way to reset the widths or heights, etc... zero images displayed... but I finally made it. This saved me thousands of pains...

As for replicating images... I'm about to work on that.

ergophobe




msg:4465300
 5:19 am on Jun 14, 2012 (gmt 0)

Oh... the cache - install the admin toolbar and empty the cache frequently when doing this sort of thing.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Content Management
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved