Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The added patches open the door to use more parameters to configure/administer/develop the image inserts.
It is now possible:
Advanced image grouping; see example code:
/**
* Preprocess variables for the pirobox-insert-image.tpl.php file.
*/
function template_preprocess_pirobox_insert_image(&$variables) {
// Group images.
$variables['gallery_id'] = '';
switch (variable_get('pirobox_insert_gallery', 0)) {
case 0:
// Post
$variables['gallery_id'] = 'gallery-' . $variables['node']->nid;
break;
case 1:
// Page
$variables['gallery_id'] = 'gallery-all';
break;
case 2:
// Field post
$variables['gallery_id'] = 'gallery-' . $variables['node']->nid . '-' . $variables['item']['field_name'];
break;
case 3:
// Field page
$variables['gallery_id'] = 'gallery-' . $variables['item']['field_name'];
break;
case 4:
// Post per user
$variables['gallery_id'] = 'gallery-' . $variables['node']->nid . '-user-' . $variables['item']['uid'];
break;
case 4:
// Per user
$variables['gallery_id'] = 'gallery-user-' . $variables['item']['uid'];
break;
case 6:
// No gallery
$variables['gallery_id'] = rand();
break;
}
}
I wait for include this patches to contribute the upcoming Pirobox module.
Comment | File | Size | Author |
---|---|---|---|
#10 | insert.patch | 4.5 KB | quiptime |
#6 | 2insert.module.patch | 2.98 KB | quiptime |
#6 | 2image.inc_.patch | 613 bytes | quiptime |
#6 | 2insert.inc_.patch | 767 bytes | quiptime |
#6 | 2after_patch.png | 52.38 KB | quiptime |
Comments
Comment #1
quiptime CreditAttribution: quiptime commentedbump
In order to visualize what is possible with the patches. I have attached 2 screenshots.
1. The image before_patch shows the very simple ability to configure the grouping of images - Colorbox module.
2. The image after_patch shows the enhanced ability to configure the grouping of images - Pirobox module. The selection options correspond with the sample code of the initial post.
Comment #2
quiptime CreditAttribution: quiptime commented@quicksketch,
I'm waiting for feedback.
Comment #3
quiptime CreditAttribution: quiptime commented@quicksketch,
please take a look at my Pirobox module issue: http://drupal.org/node/1339636
Comment #4
quicksketchI don't know about this patch because in Drupal 7, Insert (like other fields) can now be used on anything, not just nodes. This patch certainly wouldn't work for users, terms, or comments.
Comment #5
quiptime CreditAttribution: quiptime commentedRight, does not work with the entity types user, comment and taxonomy term. This is not a problem. I've changed my patches.
Now they are working with the entity types node, comment and taxonomy term. The entity type user are not included.
I'll post soon the updated patches.
But, it exist a bug in the Insert module. Because of this bug, it is not possible to insert images into comments and terms. This bug is known but unfortunately not yet fixed.
Comment #6
quiptime CreditAttribution: quiptime commentedHere are the announced updated patches.
This makes it possible to work with entity types node, comment and taxonomy term.
The attached image shows what is possible with the patches.
Comment #7
quiptime CreditAttribution: quiptime commentedbump
Comment #8
quicksketchHmm, I'm okay with this new approach if the following changes are made:
- Use entity_load() instead of making pseudo objects for each type in D7.
- A backport patch is also provided for D6.
If you could roll it all into a single patch too, that would also be appreciated;
Comment #9
quiptime CreditAttribution: quiptime commentedI will reorganize the patch code using entity_load() and roll out the patches into a single patch.
The backport patch for D6 coming soon after:
At the moment i develop on the new Pirobox module (with Insert module support). This has a higher priority for me as the D6 port.
The D6 port will come - I promise.
Is that for you so fine?
Comment #10
quiptime CreditAttribution: quiptime commentedHere are the announced updated patches as single patch.
NOTE
@quicksketch, think simply.
The use of entity_load() is not necessary! This produces unnecessary overload.
The needed entity informations are already available! This is based on my patches #6.
Comment #11
quiptime CreditAttribution: quiptime commentedbump
Comment #12
quicksketchHey @quiptime, not sure if you're still interested in this patch or not given it's been so long.
But the current patch has a section that doesn't make sense:
This should be more like this:
This will work with any entity, regardless of its type.
Comment #13
Snater CreditAttribution: Snater commentedBrowsing through old tickets while working on the module's D8 version, I had a look at this one. I think this is a reasonable change, except for the annotation made in the most recent comment. I would also propose to just pass on
$element
instead of loading the entity which is not required by Insert itself. Animated by this ticket, I implemented that in the D8 version. In my opinion, whatever module requires loading the entity should load it by itself.With the last comment on this ticket six years ago, I am closing this ticket. However, if there is still use for having that implemented, feel free to reopen.