Sorry, Mark … seems I’m not good at explaining today. We’re at 30+ degrees C and no A/C…
In the first example, both covermouseout and covermouseover are uploaded images (in separate fields), one picture per field. In the second example, they are just uploaded one after another in the (multifile-enables) field {cover}: two (or more) pics in one field. So, {cover[1]} would be the first image uploaded, {cover[2]} the second, and so on. My example was really stripped down because I’d like to have that extended to {cover[n]}, n=>1, being the nth uploaded file (or empty if less files were uploaded in that field.
Makes that any sense?
I guess what I’m confused about is if you use the multi enabled version people couldn’t people upload too many or too few images. meaning someone may not know to upload both a src image and a hover image. I would probably suggest the split out version, even if it is another field.
that said, i’m not really sure if there’s any current way to get at what you need. I guess you’d have to do it with PHP:
<?php
global $DB;
$row = $DB->query('SELECT field_id_XXX FROM exp_weblog_data WHERE entry_id="{entry_id}"');
$field_data = preg_split("/[\r\n]+/", $row['field_id_XXX']);
function element($ary,$key) { echo isset($ary[$key]) ? $ary[$key] : ''; }
?>
<?php element($field_data, 0); ?>
That’s off the top of my head and should work assuming there aren’t any typo’s or other silliness going on in there.
File extension calls the database 252 times in a single page!
The database is abused in this plugin. The db is queried even when you are accessing a MEMBER VARIABLE of the file class.
I slightly modified the code to hold the previous results in a static class variable. The fetch_setting() method first checks the class variable before turning to the database. The modification brought the total number of queries down to 4 (from 250+).
...
var $docs_url = 'http://docs.markhuot.com';
//drch edit
public static $uploadSettings;
//end drch
//
//constructor
...
function fetch_setting( $upload_id, $setting )
{
global $DB, $PREFS;
/* drch edit */
if (!isset(self::$uploadSettings[$upload_id])) {
$upload_pref = $DB->query("SELECT * FROM exp_upload_prefs WHERE id='".$upload_id."'");
self::$uploadSettings[$upload_id] = $upload_pref->row;
}
$row = self::$uploadSettings[$upload_id];
if(isset($row['properties']) && $row['properties'] != "") parse_str($row['properties']);
$val = isset($row[$setting]) ? $row[$setting] : (isset($$setting) ? $$setting : (isset($this->settings[$setting]) ? $this->settings[$setting] : ""));
/*end drch edit */
if($val == "")
{
switch($setting)
{
case "url":
$val = preg_replace("/\/$/", "", $PREFS->core_ini['site_url'])."/images/uploads/";
break;
case "server_path":
$val = preg_replace("/\/$/", "", PATH).'/../images/uploads/';
break;
case "store_thumbs_separately":
$val = 'no';
break;
case "thumb_width":
$val = '200';
break;
case "thumb_height":
$val = '200';
break;
case "allow_multiple":
$val = 'no';
break;
case "show_preview":
$val = 'no';
break;
}
}
if($val == 'yes') $val = true;
else if($val == 'no') $val = false;
return $val;
}
The extension works when I use small images and documents, but I need to upload a large 10mb audio file. It takes about 5 minutes for the file to upload, then the publish page just disappears and does not direct to the preview as it normally does.
Any clue what might be causing this?
Hi davenport,
Sorry for butting in on the end of this thread like this and so I haven’t been following this fully but are you by any chance using Safari?
If so, have you turned off the cache in Safari?
This would have been done using a fairly techy tool such as MacPilot or Cocktail as I don’t think there is an easy way to do if from the actual Safari preferences pane.
If you re-enable the cache then all should be fine. Safari uses the cache as a temporary storage place for file uploads and so if this it disabled all will go to pot!!
If you aren’t on Safari then I apologize for butting in like this but just thought that this might help. It still might help others who are having problems though so hopefully helpful somewhere.
If you have never used either MacPilot or Cocktail then it may have been an extension or something else that would have caused this problem.
If you aren’t using Safari then maybe the cache in Windows works the same way? I’m not sure about that though as I haven’t ever touched a PC so wouldn’t know but may be something worth looking into?
Hope this helps yourself or others out there.
Best wishes,
Mark
@davenport - this could be a problem with your PHP or Apache configuration. Can you try uploading the same file through the built in EE interface. Does it work? Also, try somewhat smaller files? 9MB, 8MB, 7MB, 6MB. Where does it cut off?
There are a bunch of factors limiting large uploads on the web. First PHP has a limit for uploaded file sizes, then it’s got a limit on POST data size, both of those will have to be raised above their typical size of 2MB. And then of course there’s PHP memory limit, which will probably have to be raised also. Whenever I have a client uploading files larger than ~2M I usually have them us a FTP client, and then just have them insert the file name into a text field. That way they get a nice progress indicator and everything is a lot more stable.
A hcrap, I’m getting an error when uploading on a local server (wasn’t a problem with 1.5.2 on the same server).
The error I am getting is -
Warning: move_uploaded_file(C:/dev/manag/admin/C:/dev/manag/images/uploads/hambo.jpg) [function.move-uploaded-file]: failed to open stream: Invalid argument in C:\dev\manag\admin\extensions\ext.file.php on line 552
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:\Program Files\xampp\tmp\php26C.tmp’ to ‘C:/dev/manag/admin/C:/dev/manag/images/uploads/hambo.jpg’ in C:\dev\manag\admin\extensions\ext.file.php on line 552
I would like to know what files I’d need to change if I wanted to have the control panel part of this extension execute a custom script on uploading of images.
I’d also like to change the file paths, unique folder for each article entry group, and change the image names based on the date and categories.
Thanks.
** If what is above is possible… I’d like to then add a sorting option so the image order can be sorted. Then I’d also like to be able to crop and rotate images. Add captions and titles. Add a zip uploader feature so the images can be uploaded and processed by a client in bulk without ftp.
*** I’m really not impressed by the EE image gallery. It’s doesn’t work well for the clients I’ve had. It makes the most sense to me to have the gallery attached to the Articles, then you could have a seperate gallery weblog for a specific gallery.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.