Image Title port to D6

tayzlor - October 1, 2008 - 14:24
Project:Image Title
Version:5.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi there,
i've ported this module to drupal 6. could you please review the code and get back to me if you are happy / require any changes to the module.

its been updated to use the new D6 hook_schema() for the install files.
I've also altered how the image title is displayed on 'view'.
instead of using hook_nodeapi() to do a drupal_set_title() i've updated support for the new template_preprocess functions in drupal 6.
This exposes the image title to the page.tpl in the variable $node->title if it is available.
it is also improved so that the browser title bar text remains, as previously using drupal_set_title() with the image, completely wiped the title bar attribute.

I've included the $node->title text inside a tag in the variable which is being passed up also. This is merely for search engine optimisation reasons - so Google can still index your H1 text, as opposed to it only being an image tag.

For this reason in your style.css you should include

h1.title span{
  display:none;
}

to display only the image on screen but allow the node title to be indexed by search engines still.
might be worth including this in the readme.txt

Thanks
Graham.

AttachmentSize
image_title.patch11.68 KB

#1

greg.harvey - October 7, 2008 - 14:50

Using this patch and it works well. +1 from me.

BTW, I am working on additional functionality for 6.x which will hook in to the menu_router table allowing an image title on ANY PAGE, not just nodes. The sooner a proper 6.x-1.x-dev version is created using Graham's patch, the sooner I can contribute my work. =)

#2

greg.harvey - October 29, 2008 - 13:30
Category:support request» task

Actually, I didn't have time to wait, so I've forged on. I think Graham's patch above is fine as a version 6.x-1.x-dev (a straight swap for the 5.x dev snapshot), but while I was at it I re-wrote a lot of the module. I also included a proper install file with a tested upgrade path from 5.x-1.x-dev to this version. Changes are:

  • additional permission for admin rights
  • additional admin include file with admin form and associated functions
  • admin form for setting the location of the folder you wish to save image titles in
  • hook_menu() for the admin form
  • hook_form_alter() modified so status checkbox becomes delete image checkbox (like the image module so more intuitive)
  • hook_nodeapi() behaviour changed so:
    • It no longer sets status (status field defunct)
    • file saving moved to insert/update ops
    • validate reserved for validation
    • new delete op for tidying up files and db entries for deleted nodes
  • image_title table renamed image_title_node
  • new standalone upload form (copy of the existing - though modified - hook_form_alter() code)
  • new validate and submit functions for this form, mimicking the hook_nodeapi() behaviours for non-node pages
  • new table called image_title_menu for handling non-node pages
  • new hook_cron() for cleaning up after deleted non-node pages
  • additions to Graham's preprocess function (above) to handle non-node pages
  • new hook_block() for presenting the title image upload form as a block on non-node pages
  • full install and upgrade paths provided

I *think* that's all. Files are attached. Will provide a patch for the .install and .module files against latest dev snapshot, if required, but probably easier just to try out the attached files. On Drupal 6, copy them all to an image_title directory in a valid modules folder, rename removing the .txt extensions and install. If you're upgrading from D5 to D6, this upgrade path should work too. I tried it and it worked fine running update.php.

This would probably even qualify as a 6.x-2.x-dev release! =)

I'm off for a well-earned beer.

*** PLEASE USE MODULE IN COMMENT CODE #4 BELOW ***

AttachmentSize
image_title.admin_.inc_.txt 1.3 KB
image_title.info.txt 129 bytes
image_title.install.txt 2.13 KB
readme.txt 1.79 KB

#3

greg.harvey - October 30, 2008 - 18:08

And here are all the changes as patch files, ready to be applied to head. Note the readme was updated too.

*** MODULE PATCH IS OUT OF DATE - ONCE APPLIED, PLEASE DIFF AGAINST THE MODULE CODE IN COMMENT #4 BELOW AND APPLY THE CHANGES ***

AttachmentSize
image_title.admin_.inc_.patch 1.54 KB
image_title.info.patch 628 bytes
image_title.install.patch 2.89 KB
image_title.module.patch 18.58 KB
readme.txt.patch 2.44 KB

#4

greg.harvey - October 30, 2008 - 18:08

Minor bugs:

- fixed the hook_cron to stop a PHP warning occuring
- removed a legacy call to an image.module function not used for anything
- added additional if statement to file delete on save of new image_title, to make sure we don't delete the file we're uploading in case of some file corruption

Full module attached.

AttachmentSize
image_title.module.txt 11.99 KB

#5

jonnyplunder - June 23, 2009 - 19:48

Thanks for the D6 update, but is there any reason why the image title is displayed under the existing text title? I mean, no offence or anything, but if I wanted that then I'd just use an image tag in the content itself.

I'm still poking around, but I'm not seeing any way to make it so the image title replaces the text one.

#6

greg.harvey - June 23, 2009 - 19:55

You're supposed to use CSS to hide the H1 title. It's still there for SEO. The reason to use this instead of an image in the body is this outputs the image in the $title variable, whereas an image in the body is just that - you have no additional control over where it appears - it will always be stuck in $content in your template.

#7

joachim - August 7, 2009 - 16:56

@greg.harvey -- sounds like some very cool work there! You should really apply for maintainership of this if it's abandoned and get this committed, as it's getting very hard to follow what's what in these attachments!

#8

greg.harvey - August 21, 2009 - 11:36

I probably should, since the issue queue appears to be dead.

Edit: T'is done: #555654: Request to take over maintainership/co-maintainership

 
 

Drupal is a registered trademark of Dries Buytaert.