CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Overiding img attributes site-wide
Pages: [1]

Author Topic: Overiding img attributes site-wide  (Read 1348 times)

JoopSJ

  • I post occasionally
  • **
  • Posts: 80
  • Karma: 2
Overiding img attributes site-wide
October 22, 2009, 12:28:48 am
I'm using the file-field customfield to display a contact's photograph.
To preserve the aspect ratio I deleted the width=100 attribute. I did this for the Contact Summary View and Edit pages by overriding the template-files. I can't find the template files to override for profile pages.

Maybe better: Where can I find the class to override the img attributes, so the change is applied Civi-wide?
Photo -ID pictures in Europe tend to be rectangular as opposed to square in the US.
Thanks

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Overiding img attributes site-wide
October 22, 2009, 05:32:45 am
I've run into this as well. I think we need to develop a better way to handle this in general, as the existing code is unhelpful for just about any situation except one in which all images are the exact size of the hardcoded dimensions.

The file you need to modify is:
CRM/Core/BAO/CustomField.php
around line 1148 (in the v2.2 codebase) -- look for: $result['file_url']

-Brian
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

JoopSJ

  • I post occasionally
  • **
  • Posts: 80
  • Karma: 2
Re: Overiding img attributes site-wide
October 22, 2009, 06:26:24 am
Thanks Brian,
that was exactly the place to be.

Quote from: lcdweb on October 22, 2009, 05:32:45 am
I think we need to develop a better way to handle this in general, as the existing code is unhelpful for just about any situation except one in which all images are the exact size of the hardcoded dimensions.

Maybe a good starting point is not to set the width atrribute in Core.
Joop


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Overiding img attributes site-wide
October 22, 2009, 08:50:37 am

Would be great for someone to submit a patch that does scale the photograph relative to its current dimesions. Should not be too hard a project. Quite a few folks have encountered this issue, but no one seems to be willing to step up and provide a patch. We can help direct and guide you :0

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

JoopSJ

  • I post occasionally
  • **
  • Posts: 80
  • Karma: 2
Re: Overiding img attributes site-wide
October 22, 2009, 12:07:34 pm
Hello Lobo,
would it really be neccesary to scale it according excisting proportions? If you keep the height to 100px you will be sure the default civicrm screen layout is preserved nicely. Just deleting the width will suite my needs, but maybe there are more use-cases I'm not aware of.
Regards, Joop

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Overiding img attributes site-wide
October 22, 2009, 01:13:09 pm
Well, you can easily upload a 100 height and 100000 width picture, that might have a negative impact on the layout ;)

By creating a thumbnail, you are sure to avoid that, you have a quicker page (you don't download a 10Mb picture to display a 100px high), and  visually, the resizing of the client side by setting the height/width gets an uglier result than doing it on the server.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Overiding img attributes site-wide

This forum was archived on 2017-11-26.